Liquid Filters
Liquid Filters
Section titled “Liquid Filters”Standard Filters
Returns an absolute value of a number e.g. {% raw %}
{{ -17 | abs }} }} #=> 17{% endraw %}
append
Section titled “append”append a string e.g. {% raw %}
{{ 'foo' | append:'bar' }} #=> 'foobar'{% endraw %}
capitalize
Section titled “capitalize”capitalize words in the input sentence
rounds a number up to the nearest integer, e.g. {% raw %}
{{ 4.6 | ceil }} #=> 5{% endraw %}
reformat a date (syntax reference)
default
Section titled “default”returns the given variable unless it is null or the empty string, when it will return the given value, e.g. {% raw %}
{{ undefined_variable | default: "Default value" }} #=> "Default value"{% endraw %}
{% raw %}
{{ product_price | default: 2.99 }} #=> 2.99{% endraw %}
{% raw %}
{% assign product_price = 4.99 %} {{ product_price | default: 4.99 }} #=> 4.99{% endraw %}
divided_by
Section titled “divided_by”integer division e.g. {% raw %}
{{ 10 | divided_by:3 }} #=> 3{% endraw %}
downcase
Section titled “downcase”convert an input string to lowercase
escape_once
Section titled “escape_once”returns an escaped version of html without affecting existing escaped entities
escape
Section titled “escape”html escape a string
get the first element of the passed in array
rounds a number down to the nearest integer, e.g. {% raw %}
{{ 4.6 | floor }} #=> 4{% endraw %}
join elements of the array with certain character between them
get the last element of the passed in array
lstrip
Section titled “lstrip”strips all whitespace from the beginning of a string
map/collect an array on a given property
subtraction e.g. {% raw %}
{{ 4 | minus:2 }} #=> 2{% endraw %}
modulo
Section titled “modulo”remainder, e.g. {% raw %}
{{ 3 | modulo:2 }} #=> 1{% endraw %}
newline_to_br
Section titled “newline_to_br”replace each newline (\n) with html break
addition e.g. {% raw %}
{{ '10' | plus:'1' }} #=> 11{% endraw %}
prepend
Section titled “prepend”prepend a string e.g. {% raw %}
{{ 'bar' | prepend:'foo' }} #=> 'foobar'{% endraw %}
remove_first
Section titled “remove_first”remove the first occurrence e.g. {% raw %}
{{ 'barbar' | remove_first:'bar' }} #=> 'bar'{% endraw %}
remove
Section titled “remove”remove each occurrence e.g. {% raw %}
{{ 'foobarfoobar' | remove:'foo' }} #=> 'barbar'{% endraw %}
replace_first
Section titled “replace_first”replace the first occurrence e.g. {% raw %}
{{ 'barbar' | replace_first:'bar','foo' }} #=> 'foobar'{% endraw %}
replace
Section titled “replace”replace each occurrence e.g. {% raw %}
{{ 'foofoo' | replace:'foo','bar' }} #=> 'barbar'{% endraw %}
reverse
Section titled “reverse”reverses the passed in array
rounds input to the nearest integer or specified number of decimals e.g. {% raw %}
{{ 4.5612 | round: 2 }} #=> 4.56{% endraw %}
rstrip
Section titled “rstrip”strips all whitespace from the end of a string
return the size of an array or string
slice a string. Takes an offset and length, e.g. {% raw %}
{{ "hello" | slice: -3, 3 }} #=> llo{% endraw %}
sort elements of the array
split a string on a matching pattern e.g. {% raw %}
{{ "a~b~c" | split:"~" }} #=> ['a','b', 'c']{% endraw %}
{% raw %}
{% assign beatles = "Usage, Adoption, Retention, Renewal, Revenue Expansion" | split: ", " %} {% for member in beatles %} {{ member }}{% endfor %}#=>Usage
Adoption
Retention
Renewal
Revenue Expansion{% endraw %}
strip_html
Section titled “strip_html”strip html from string
strip_newlines
Section titled “strip_newlines”strip all newlines (\n) from string
strips all whitespace from both ends of the string
multiplication e.g
{% raw %}
{{ 5 | times:4 }} #=> 20{% endraw %}
truncate
Section titled “truncate”truncate a string down to x characters. It also accepts a second parameter that will append to the string e.g. {% raw %}
{{ 'foobarfoobar' | truncate: 5, '.' }} #=> 'foob.'{% endraw %}
truncatewords
Section titled “truncatewords”truncate a string down to x words
removed duplicate elements from an array, optionally using a given property to test for uniqueness
upcase
Section titled “upcase”convert an input string to uppercase
url_encode
Section titled “url_encode”url encode a string