Google app engine Can';t在jinja2中禁用自动转义
在GAE中,我将jinja2和autoescape一起使用,一切都很好Google app engine Can';t在jinja2中禁用自动转义,google-app-engine,escaping,jinja2,Google App Engine,Escaping,Jinja2,在GAE中,我将jinja2和autoescape一起使用,一切都很好 import jinja2 jinja_env = jinja2.Environment(loader = jinja2.FileSystemLoader(template_dir), autoescape = True) 在一个模板中,我不想要自动转义,因此我尝试如下禁用它: {% autoescape false %} {{content}} {% endautoescape %} jinja_env = jinja
import jinja2
jinja_env = jinja2.Environment(loader = jinja2.FileSystemLoader(template_dir), autoescape = True)
在一个模板中,我不想要自动转义,因此我尝试如下禁用它:
{% autoescape false %}
{{content}}
{% endautoescape %}
jinja_env = jinja2.Environment(loader = jinja2.FileSystemLoader(template_dir),
autoescape = True,
extensions = ['jinja2.ext.autoescape'])
当渲染此模板时,我收到消息“遇到未知标记“autoescape”。为了识别
autoescape
标记,您需要在设置jinja2时启用autoescape扩展,如下所示:
{% autoescape false %}
{{content}}
{% endautoescape %}
jinja_env = jinja2.Environment(loader = jinja2.FileSystemLoader(template_dir),
autoescape = True,
extensions = ['jinja2.ext.autoescape'])
此外,请确保您在app.yaml(is 2.6)中使用的是jinja2 2.4版或更高版本:
有关详细信息,请参阅。尝试以下方法:
{{ content | safe}}
文件: