Yoolk Liquid

Home Filters Sanitize-filters

Sanitize Filters

Provides a set of methods for scrubbing text of undesired HTML elements.

strip_tags

Strips all HTML tags from the html, including comments. This uses the html-scanner tokenizer and so its HTML parsing ability is limited by that of html-scanner.

{{ "Strip <i>these</i> tags!" | strip_tags }}
# => Strip these tags!

{{ "<b>Bold</b> no more!  <a href='more.html'>See more here</a>..." | strip_tags }}
# => Bold no more!  See more here...

{{ "<div id='top-bar'>Welcome to my website!</div>" | strip_tags }}
# => Welcome to my website!

Strips all link tags from text leaving just the link text.

{{ '<a href="http://www.rubyonrails.org">Ruby on Rails</a>' | strip_links }}
# => Ruby on Rails

{{ 'Please e-mail me at <a href="mailto:me@email.com">me@email.com</a>.' | strip_links }}
# => Please e-mail me at me@email.com.

{{ 'Blog: <a href="http://www.myblog.com/" class="nav" target=\"_blank\">Visit</a>.' | strip_links }}
# => Blog: Visit.