Parse and output HTML code without escaping

How to parse and output HTML code without escaping in the Anqi CMS template?

safeThe filter can cancel the default escaping attribute of template output, allowing direct output of HTML code to the interface for the browser to parse the HTML code.Generally used in rich text output, such as displaying article details and similar cases.

Note:safeFilter, it is assumed by default that your output is safe, it does not escape special characters, so if there are issues such as XSS injection in the code, it will also output it as is.Please be vigilant about risks.

Usage Instructions

safeHow to use the filter:

{{ obj|safe }}

For example, to transform<script>To preserve the output without escaping, you can write it like this:

{{ "<script>"|safe }}
# 显示结果
<script>

Here is an example demonstration

{{ "<script>"|safe|escape }}
{{ "<script>"|safe|e }}

Display results

&lt;script&gt;
<script>