How to remove tags from HTML code in Anqi CMS template?
striptags
The filter can remove all HTML tags from the HTML code.
removetags
The filter can remove a specified tag from the HTML code.
Usage Instructions
striptags
How to use the filter:
{{ obj|striptags }}
removetags
How to use the filter:
{{ obj|removetags:"标签" }}
Can remove multiple tags, separated by,
separated.
For example, to remove<strong><i>Hello!</i></strong>
the i tag, it can be written as:
{{ "<strong><i>Hello!</i></strong>"|removetags:"i"|safe }}
# 显示结果
<strong>Hello!</strong>
Here is an example demonstration
{{ "<strong><i>Hello!</i></strong>"|striptags|safe }}
{{ "<strong><i>Hello!</i></strong>"|removetags:"i"|safe }}
{{ "<strong><i>Hello!</i><span>AnQiCMS</span></strong>"|removetags:"i,span"|safe }}
# 显示结果
Hello!
<strong>Hello!</strong>
<strong>Hello!</strong>