html functionsHtml functions available through the builtin object 'html'.
html.striphtml.strip <text>
Removes any HTML tags from the input string
text: The input stringThe input string removed with any HTML tags
Notice that the implementation of this function is using a simple regex, so it can fail escaping correctly or timeout in case of the malformed html. If you are looking for a secure HTML stripped, you might want to plug your own HTML function by using AngleSharp to strip these HTML tags.
input Try out
{{ "<p>This is a paragraph</p>" | html.strip }}
output
This is a paragraph
html.escapehtml.escape <text>
Escapes a HTML input string (replacing & by &)
text: The input stringThe input string removed with any HTML tags
input Try out
{{ "<p>This is a paragraph</p>" | html.escape }}
output
<p>This is a paragraph</p>
html.newline_to_brhtml.newline_to_br <text>
Inserts an HTML line break (<br /> in front of each newline (\r\n, \r, \n) in a string
text: The input stringThe input string with HTML line breaks
input Try out
{{ "Hello\nworld" | html.newline_to_br }}
output
Hello<br />
world
html.url_encodehtml.url_encode <text>
Converts any URL-unsafe characters in a string into percent-encoded characters.
text: The input stringThe input string url encoded
input Try out
{{ "john@liquid.com" | html.url_encode }}
output
john%40liquid.com
html.url_escapehtml.url_escape <text>
Identifies all characters in a string that are not allowed in URLS, and replaces the characters with their escaped variants.
text: The input stringThe input string url escaped
input Try out
{{ "<hello> & <scriban>" | html.url_escape }}
output
%3Chello%3E%20&%20%3Cscriban%3E
Note: This document was automatically generated from the source code using
Scriban.DocGen.