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 the specified tags in the html code.
How to use
striptags
How to use filters:
{{ obj|striptags }}
removetags
How to use filters:
{{ obj|removetags:"tag" }}
Multiple tags can be removed, and used between multiple tags,
Separate.
For example, remove<strong><i>Hello!</i></strong>
The Chinese i tag can be written like this:
{{ "<strong><i>Hello!</i></strong>"|removetags:"i"|safe }} # Show results <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 }} # Show results Hello! <strong>Hello!</strong> <strong>Hello!</strong>