在django模板中如何逃避{{或}}? [英] How to escape {{ or }} in django template?
本文介绍了在django模板中如何逃避{{或}}?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Django将 {{var}}
视为模板中的一些变量。如何逃避 {{var}}
或 {{
或}}
,使django不将其视为变量。
Django treats {{ var }}
as some variable in its template. How can I escape {{ var }}
or {{
or }}
such that django does not treat it as variable.
< p>{{some text}}< / p>
应该打印完全一样。
推荐答案
我相信你在寻找 templatetag
模板标签。
I believe you are looking for the templatetag
template tag.
随着链接到doc的说明,
As the linked-to doc states,
由于模板系统没有概念转义,要显示模板标签中使用的位之一,您必须使用
{%templatetag%}
标签。
例如:
<p>"{% templatetag openvariable %} some text {% templatetag closevariable %}"</p>
将显示为:
<p>"{{ some text }}"</p>
这篇关于在django模板中如何逃避{{或}}?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文