Remove HTML tags from HTML code

How to remove tags from HTML code in Anqi CMS template?

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

removetagsThe filter can remove a specified tag from the HTML code.

Usage Instructions

striptagsHow to use the filter:

{{ obj|striptags }}

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