Randy Tang
Randy Tang

Reputation: 4353

Google app engine: how to display html file

I have a model:

class Product(db.Model):
    ...
    file: db.BlobProperty()  # Uploaded HTML file for product description
    ...

and I would like to display it in a page using the template system:

<div style="height:200px; overflow:auto;">{{product.file}}</div>

However, this shows a plain text with all HTML tags visible. How do I display such file correctly?

Upvotes: 1

Views: 110

Answers (1)

RocketDonkey
RocketDonkey

Reputation: 37249

Assuming your are using jinja2 (if not, this can be updated), try passing your product.file variable through the safe function:

<div style="height:200px; overflow:auto;">{{product.file|safe}}</div>

This indicates that the value is 'safe' and can be rendered without escaping. See here for more (jinja2-related) information on HTML escaping.

Upvotes: 2

Related Questions