Filters for HTML Operations with Scriptlets
Scriptlets make it easy to output HTML-safe content for rich emails. For instance, it can convert newlines to <br> tags, or escape HTML characters like &.
escape
Section titled “escape”Escape a string
{? "Ben & Jerry" | escape ?}Output
Ben & Jerry
{? "Ben & Jerry > Peter" | escape ?}Output
Ben & Jerry > Peter
{? "Ben & Jerry" | escape ?}Output
Ben &amp; Jerry
escape_once
Section titled “escape_once”Escape a string but ignore all escaped HTML entities
{? "Ben & Jerry > Peter" | escape_once ?}Output
Ben & Jerry > Peter
url_encode
Section titled “url_encode”Converts any URL-unsafe characters in a string into percent-encoded characters.
{? "Email us at amit@labnol.org" | url_encode ?}Output
Email+us+at+amit%40labnol.org
url_decode
Section titled “url_decode”Decodes a string that is encoded as a URL
{? "Sent+from%20amit%40labnol.org" | url_decode ?}Output
"Sent from amit@labnol.org"
newline_to_br
Section titled “newline_to_br”Convert any newline characters in the input text to HTML <BR> line break tags
{? "Apple, Orange, Mango" | split: ", " | join: "\n" | newline_to_br ?}Output
Apple<br />\nOrange<br />\nMango
HTML Table
Section titled “HTML Table”The next example shows how to create an HTML table using the first two elements of the input array.
{% assign fruitArray = "Apple, Orange, Mango" | split: ", " %}<table> {% tablerow fruit in fruitArray cols:1 limit:2 %} {? fruit ?} {% endtablerow %}</table>The output table does not contain “Mango”.
