autoescape 模板標籤
定義和用法
autoescape
標籤用於指定是否開啟自動轉義。
如果開啟了 autoescape
(這是預設設定),則變數中的 HTML 程式碼會被轉義。
開啟轉義時,這些字元會被轉義
<
會被轉換為<
>
會被轉換為>
'
會被轉換為'
"
會被轉換為"
&
會被轉換為&
示例
當自動轉義開啟時,變數中的任何 HTML 元素都會根據上面的列表進行轉換。
{% autoescape on %}
<h1>{{ heading }}</h1>
{% endautoescape %}
執行示例 »
語法
{% autoescape on|off %}
...
{% endautoescape %}
引數
值 | 描述 |
---|---|
on | 預設。指定該塊將被轉義 |
off | 指定該塊將不被轉義 |