How to remove tags from HTML code in the AnQi CMS template?
striptags
The filter can remove all HTML tags from the HTML code.
removetags
The filter can remove specified tags from html code.
How to use
striptags
How to use filters:
{{ obj|striptags }}
removetags
How to use filters:
{{ obj|removetags:"标签" }}
Multiple tags can be removed, and used between multiple tags,
Separate.
For example, remove<strong><i>Hello!</i></strong>
If you want to remove the i tag, you can write it like this:
{{ "<strong><i>Hello!</i></strong>"|removetags:"i"|safe }}
# 显示结果
<strong>Hello!</strong>
Sample Demo
{{ "<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>