Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do I include quoted HTML in a Tornado Template?

I'm using Tornado Templates and one of my fields is a string that has HTML tags quoted in it, e.g. <p>Solar power</p>

When I render it into the template, the tags are quoted verbatim instead of treated as tags. {{ quoted_html }} So it looks exactly as above with the p tag visible.

In other templating systems, {{ = foo}} renders foo verbatim, but {{html foo}} treats the tags as tags.

Is there the equivalent in Tornado Templates?

like image 974
Brad Avatar asked Jun 29 '11 22:06

Brad


1 Answers

{% raw foo %}, in Tornado 2.0+.

If you do that with a lot of expressions in a template, you can add the {% autoescape None %} directive to the beginning of the template, after which {{ foo }} will not be escaped.

like image 167
Cole Maclean Avatar answered Sep 21 '22 18:09

Cole Maclean