How to parse HTML code without escaping in Anqi CMS template?
safeThe filter can cancel the default escaping attribute of the 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 the like.
Note: UsesafeThe filter defaults to considering your output safe, it does not escape special characters, so if there are issues such as XSS injection in the code, it will also output them as is.Please be vigilant of risks.
Usage method
safeHow to use the filter:
{{ obj|safe }}
For example, to convert<script>To preserve the output without escaping, you can write it like this:
{{ "<script>"|safe }}
# 显示结果
<script>
Example Demonstration
{{ "<script>"|safe|escape }}
{{ "<script>"|safe|e }}
Display result
<script>
<script>