在{%block content%}中放入瓶中的新行 [英] New lines in flask within {%block content%}

查看:419
本文介绍了在{%block content%}中放入瓶中的新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,如果我要做一些像 {%block content%}
{{variable}}
{%endblock%}

在我的HTML和变量等于Test< br /> test2怎么了
打印出来,不会换新的一行?有没有办法解决这个问题?

/ templating /#controls-autoescapingrel =noreferrer>自动转义特殊字符。可能最简单的方法是使用 safe 过滤器:

  {{安全}} 


So if I were to do something like {% block content %} {{variable}} {% endblock %} in my HTML, and variable is equal to "Test <br /> test2" how come the
prints out and does not make a new line? is there a way to fix this?

解决方案

Jinja2 automatically escapes special characters for you. Probably simplest way is to use safe filter:

{{ variable|safe }}

这篇关于在{%block content%}中放入瓶中的新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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