Skip to main content

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 _self if the URL starts with / (internal link).
  • Returns _blank if the URL starts with https:// (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>