HTML & String Handling Filters
This section covers filters that manipulate HTML and string content.
html_decode
Decodes HTML entities back to readable HTML.
Usage
{{ "<p>test</p>" | html_decode | raw }}
remove_html
Removes all HTML tags from a string.
Usage
{{ "<p>test</p>" | remove_html | raw }}
target
Returns the appropriate target attribute for a link.
- Returns
_selfif the URL starts with/(internal link). - Returns
_blankif the URL starts withhttps://(external link).
Usage
This will return _self:
<a href="/test" target="{{ '/test' | target }}" class="btn btn-primary">
<i class="fa-solid fa-arrow-right"></i> Testing
</a>
This will return _blank:
<a href="https://google.com" target="{{ 'https://google.com' | target }}" class="btn btn-primary">
<i class="fa-solid fa-arrow-right"></i> Google testing
</a>