简体   繁体   English

Django模板:动态更改标签?

[英]Django template: change tags dynamically?

I would like to change some tags dynamically at Django template, for example: 我想在Django模板中动态更改一些标签,例如:

{% autoescape on %}
{% endautoescape %}

Here the autoescape is on, but I like to change to 这是自动转义功能,但我想更改为

{% autoescape off %}
{% endautoescape %}

by submitting a button value at user's side. 通过在用户端提交按钮值。 How could I treat "on" and "off" as a variable here? 我如何在这里将“ on”和“ off”视为变量? (Does django template language has a mechanism like C's macro? ) (django模板语言是否具有类似于C的宏的机制?)

If you want to turn off autoescape temporarily, consider 如果要暂时关闭自动转义,请考虑

{{ something | safe }}

where the something will not be escaped. 那里的something将无法逃脱。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM