how do I include quoted HTML in a Tornado Template

2019-01-23 13:54发布

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?

1条回答
叼着烟拽天下
2楼-- · 2019-01-23 14:32

{% 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.

查看更多
登录 后发表回答