Html

Html

{{ html }}

Name Type Description
is_valid Boolean True if the value is not empty
value String The HTML input. If there are any <liquid-markup> tags, they will be evaluated exactly once. Multiple references to value will yield the same result
plain_value String The HTML input exactly as it was entered. Anytags will NOT be evaluated before returning the result
interpreted_value String Identical to value, except that template code insidetags will be evaluated every time interpreted_value is referenced
default_value String The default value (plain/uninterpreted) for this field if no value is specified
field_id String The identifier for this field
label String The label for this field
output String Same as value - except that output is clickable in the preview site while value is not. May include additional markup in the editor preview to make it easier to edit content

Allows any valid HTML input. May also include <liquid-markup> tags.

html_encode filter

Encode a string to be output as HTML. All special HTML characters will be converted to their equivalent HTML character entities (eg: < becomes <). This is functionally identical to the escape filter, though it may be more intuitive in some contexts - such as when using both the html_encode and html_decode filters to execute more advanced string manipulation.

html_encode

Examples

Encode a string for output inside other HTML markup.

Encode HTML entities in a string

Copy

A string with HTML & other characters

" | html_encode}}">...

html_decode filter

Decodes any encoded HTML entities (eg: &lt; becomes <)

html_decode

Examples

Decode any encoded HTML entities inside a string.

Decode HTML entities in a string

Copy
{{"<p>A string with HTML & other characters</p>" | html_decode}}

strip_html filter

Removes all HTML tags from a string

strip_html

Examples

Strip HTML from an input string

Copy
{{'

The quick brown fox jumps over the lazy dog.

' | strip_html}}
{% capture input -%}

The quick brown fox jumps over the lazy dog.


note that this will also strip images {%- endcapture -%} {{input | strip_html | strip}}

Could result in unexpected behavior with poorly formatted input

{% capture input -%} //script outside of a script tag if (a < b) doSomething(); if(a > b) doSomethingElse(); //endscript {%- endcapture -%} {{input | strip_html | strip}}

Could result in unexpected behavior with poorly formatted input

{% capture input -%}

The following invalid markup contains an unescaped > character in an HTML attribute:

{%- endcapture -%} {{input | strip_html | strip}}

Examples

Strip HTML from an input string

Copy
{{'

The quick brown fox jumps over the lazy dog.

' | strip_html}}
{% capture input -%}

The quick brown fox jumps over the lazy dog.


note that this will also strip images {%- endcapture -%} {{input | strip_html | strip}}

Could result in unexpected behavior with poorly formatted input

{% capture input -%} //script outside of a script tag if (a < b) doSomething(); if(a > b) doSomethingElse(); //endscript {%- endcapture -%} {{input | strip_html | strip}}

Could result in unexpected behavior with poorly formatted input

{% capture input -%}

The following invalid markup contains an unescaped > character in an HTML attribute:

{%- endcapture -%} {{input | strip_html | strip}}

Encode a string for output inside other HTML markup.

Encode HTML entities in a string

Copy

A string with HTML & other characters

" | html_encode}}">...

Decode any encoded HTML entities inside a string.

Decode HTML entities in a string

Copy
{{"<p>A string with HTML & other characters</p>" | html_decode}}

Dynamically render html tags using var

Copy
{% var tagtype = "div" %} 〈{{tagtype}}〉 {% if true %} {% var tagtype = "span" %} 〈{{tagtype}}〉Some Content 〈/{{tagtype}}〉 {% endif %} 〈/{{tagtype}}〉

Escape HTML characters in a string for output inside other HTML markup.

Escape HTML characters in a string

Copy

A string with HTML & other characters

" | escape}}">...

Escape HTML characters in a string for output inside other HTML markup. If HTML characters have already been escaped, do not "double-escape" them.

Escape HTML characters in a string once

Copy

...