Remove html tags from html code

How to remove tags from HTML code in the AnQi CMS template?

striptagsThe filter can remove all HTML tags from the HTML code.

removetagsThe filter can remove specified tags from html code.

How to use

striptagsHow to use filters:

{{ obj|striptags }}

removetagsHow 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>