无法在jinja2中禁用autoescape [英] Can't disable the autoescape in jinja2

查看:500
本文介绍了无法在jinja2中禁用autoescape的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  import jinja2 
jinja_env = jinja2 .Environment(loader = jinja2.FileSystemLoader(template_dir),autoescape = True)

不想要自动切换,所以我试图禁用它:

  {%autoescape false%} 
{ {content}}
{%endautoescape%}

是时候渲染此模板得到消息遇到未知标签'autoescape'。

解决方案

尝试这个:

  {{content | 

docs:




In GAE I use jinja2 with the autoescape, and everything works well.

import jinja2
jinja_env = jinja2.Environment(loader = jinja2.FileSystemLoader(template_dir), autoescape = True)

In one template I don't want the autoescape, so I tried to disable it like this:

{% autoescape false %}
{{content}}
{% endautoescape %}

When it's time to render this template I get the message Encountered unknown tag 'autoescape'.

解决方案

Try this:

{{ content | safe}}

docs:

这篇关于无法在jinja2中禁用autoescape的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆