Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

Operators

...

It is possible use this operator with dynamic fields 'as is' only to compare strings.

Code Block
languagexml
{% if dynamicfields.name == 'alan' %} 
alan
{% elsif dynamicfields.name == 'tom' %}
tom
{% else %}
catherine
{% endif %}

In this case the check is case sensitive.

To compare numbers or data type different from string it is possible use the built in functions:

Code Block
languagexml
{% assign c1 = dynamicfields.name| evaltext: 'equalTo', 'Jennifer' %} {% if c1 == true %} Text {% endif %}
Code Block
languagexml
{% assign c1 = dynamicfields.age | evalinteger: 'equalTo', '8' %} {% if c1 == true %} Text {% endif %}

...

Introduction

The liquid is an open-source template language created by Shopify and written in Ruby. It is the backbone of Shopify themes and is used to load dynamic content on storefronts.

In MailUp Liquid is used as a markup language for the email messages that use Advanced content personalization.

The following guide describes how to use Liquid within MailUp and which statements are supported.


When talking about dynamics fields, we refer to the MailUp Recipient fields.

To retrieve a specific dynamic field value, you have to use the following syntax: dynamicfields.<dynamic field name>.

Note

In the liquid syntax, not all characters are supported in a variable name. To be sure to have a correct syntax when using MailUp dynamic field, we recommend using only:

  • digits (0...9)
  • letters (a...z and A...Z)
  • dash (-) and underscore (_) signs


For MailUp Recipient fields that contain these characters:

  • accented characters should be substituted with normalized characters (e.g. 'CrèmeBrûlée' -> 'CremeBrulee')
  • special characters, such as full stop (.), space (' '), dollar('$'), should be removed from the field name (e.g. 'Is a colleague' -> 'Isacolleague').


Basics

Operators

OperatorMeaningWorkSyntax
==equals(tick)

This operator can be used with dynamic fields 'as is' only to compare strings.

Code Block
languagexml
{% if dynamicfields.name 
!
== 'alan' %} 
alan
{% elsif dynamicfields.name 
!
== 'tom' %}
tom
{% else %}
catherine
{% endif %}

In this case, the check is case-sensitive.

To compare numbers or data

type

types different from a string it is possible to use the built-in functions:

Code Block
languagexml
{% assign c1 = dynamicfields.name| evaltext: '
otherThan
equalTo', 'Jennifer' %} {% if c1 == true %} Text {% endif %}


Code Block
languagexml
{% assign c1 = dynamicfields.age | evalinteger: '
otherThan
equalTo', '8' %} {% if c1 == true %} Text {% endif %}
>greater than


!=does not equal(tick)

It is possible to use this operator with dynamic fields 'as is' only to compare strings.

Code Block
languagexml
{% if dynamicfields.name 
>
!= 'alan' %} 
alan
{% elsif dynamicfields.name 
>
!= 'tom' %}
tom
{% else %}
catherine
{% endif %}

In this case, the check is case-sensitive.

To compare numbers or data

type

types different from a string it is possible to use the built-in functions:

Code Block
languagexml
{% assign c1 = dynamicfields.name| evaltext: '
moreThan
otherThan', 'Jennifer' %} {% if c1 == true %} Text {% endif %}


Code Block
languagexml
{% assign c1 = dynamicfields.age | evalinteger: '
moreThan
otherThan', '8' %} {% if c1 == true %} Text {% endif %}
<less than(tick)


It is possible use

this operator with dynamic fields 'as is' only to compare strings

the operator to check if the dynamic field is empty or contains a value.

Code Block
languagexml
{% if dynamicfields.name 
<
!= '
alan
' %} 
alan {% elsif dynamicfields.name < 'tom' %} tom
Valued
{% else %}
catherine
empty
{% endif %}

In this case the check is case sensitive.

To compare numbers or data type different from string it is possible use the built


It is possible do the same using the built-in functions:

Code Block
languagexml
{% assign c1 = dynamicfields.name| evaltext: '
lessThan
otherThan', '
Jennifer
' %} {% if c1 == true %} 
Text
valued {% endif %}
code>=greater than or equal to


>
languagexml
{% assign c1 = dynamicfields.age | evalinteger: 'lessThan', '8' %} {% if c1 == true %} Text {% endif %}
greater than(tick)

It is possible to use this operator with dynamic fields 'as is' only to compare strings.

Code Block
languagexml
{% if dynamicfields.name >
=
 'alan' %} 
alan
{% elsif dynamicfields.name >
=
 'tom' %}
tom
{% else %}
catherine
{% endif %}

In this case, the check is case-sensitive.

To compare numbers or data

type

types different from a string it is possible to use the built-in functions:

Code Block
languagexml
{% assign c1 = dynamicfields.name| evaltext: '
equalOrMoreThan
moreThan', 'Jennifer' %} {% if c1 == true %} Text {% endif %}


Code Block
languagexml
{% assign c1 = dynamicfields.age | evalinteger: '
equalOrMoreThan
moreThan', '8' %} {% if c1 == true %} Text {% endif %}


<
=
less than
or equal to
(tick)

It is possible to use this operator with dynamic fields 'as is' only to compare strings.

Code Block
languagexml
{% if dynamicfields.name <
=
 'alan' %} 
alan
{% elsif dynamicfields.name <
=
 'tom' %}
tom
{% else %}
catherine
{% endif %}

In this case, the check is case-sensitive.

To compare numbers or data

type

types different from a string it is possible to use the built-in functions:

Code Block
languagexml
{% assign c1 = dynamicfields.name| evaltext: '
equalOrLessThan
lessThan', 'Jennifer' %} {% if c1 == true %} Text {% endif %}


Code Block
languagexml
{% assign c1 = dynamicfields.age | evalinteger: '
equalOrLessThan
lessThan', '8' %} {% if c1 == true %} Text {% endif %}
or


>=
logical
greater than or equal to(tick)

It is possible to use this operator with dynamic fields 'as is' only to compare strings.

Code Block
languagexml
{% if dynamicfields.name 
=
>= 'alan' 
or
%} 
alan
{% elsif dynamicfields.
age
name >=
=
 '
child
tom' %}
is alan or a child
tom
{% else %}
It is an adult alan or another adult (tick)
catherine
{% endif %}
andlogical and

In this case, the check is case-sensitive.

To compare numbers or data types different from a string it is possible to use the built-in functions:

Code Block
languagexml
{% assign 
if
c1 = dynamicfields.name| 
==
evaltext: '
alan
equalOrMoreThan'
and dynamicfields.age == 'child
, 'Jennifer' %} {% 
alan
if 
is
c1 
a child {% else
== true %} 
it is an adult
Text {% endif %}
containschecks for the presence of a substring inside a string(tick)


Code Block
languagexml
{% assign 
if
c1 = dynamicfields.
name contains
age | evalinteger: 'equalOrMoreThan', '
oof
8' %} {% 
could
if 
be
c1 
alan?
== true 
{
%
else %
} 
surely isn't alan TypeMeaningWorkSyntaxStringDeclare a string by wrapping a variable’s value in single quotes:(tick)
Text {% endif %}

Types


<=less than or equal to(tick)

It is possible to use this operator with dynamic fields 'as is' only to compare strings.

Code Block
languagexml
{% 
assign
if 
thisIsAString
dynamicfields.name <= '
this is a string
alan' %} 
{{ thisIsAString | upcase }}
Code Block
languagexml
titleOutput
THIS IS A STRING
NumberNumbers include floats and integers:(tick) Code Block
languagexml

alan
{% 
assign
elsif 
thisIsAnInteger
dynamicfields.name <= 
10
'tom' %}
tom
{
{ thisIsAnInteger | minus: 2 }} Code Block
languagexml
titleOutput
8
% else %}
catherine
{% endif %}

In this case, the check is case-sensitive.

To compare numbers or data types different from a string it is possible to use the built-in functions:

Code Block
languagexml
{% assign 
thisIsAFloat
c1 = 
10.234
dynamicfields.name| evaltext: 'equalOrLessThan', 'Jennifer' %} {
{ thisIsAFloat | minus: 2 }}
% if c1 == true %} Text {% endif %}


Code Block
languagexml
titleOutput
8.23400020599365
Boolean (tick) Code Block
languagexml
{% assign thisIsTrue =
{% assign c1 = dynamicfields.age | evalinteger: 'equalOrLessThan', '8' %} {% if c1 == true %} Text {
{
% 
thisIsTrue
endif %}
}
code


or
languagexml
titleOutput
true
logical or(tick)


Code Block
languagexml
{%
assign thisIsFalse = true
 if dynamicfields.name == 'alan' or dynamicfields.age == 'child' %} 
{{ thisIsFalse }}
Code Block
languagexml
titleOutput
false
Nil

Nil is a special empty value that is returned when Liquid code has no results. It is not a string with the characters “nil”.

Nil is treated as false in the conditions of if blocks and other Liquid tags that check the truthfulness of a statement.

(tick) Code Block
languagexml
{% if user %} Hello user!

is alan or a child
{% else %}
It is an adult alan or another adult
{% endif %}
code


and
languagexml
titleOutput
 
logical and(tick)


Code Block
languagexml
{%
unless user
 if dynamicfields.name == 'alan' and dynamicfields.age == 'child' %} 
alan is a child
{% else %}
it is 
Hello
an 
user!
adult
{% 
endunless
endif %}


containschecks for the presence of a substring inside a string(tick)


Code Block
languagexml
titleOutput
 Hello user!
ArrayArrays hold lists of variables of any type.(tick)
Code Block
languagexml
{% assign my_array = 'alan,catherine,tom,erin,mark' | split: ',' %}
{{ my_array.first }}
{{ my_array.last }}
Code Block
languagexml
titleOutput
alan mark
{% if dynamicfields.name contains 'oof' %} 
could be alan? 
{% else %} 
surely isn't alan 
{% endif %}


Types

TypeMeaningWorkSyntax
StringDeclare a string by wrapping a variable’s value in single quotes:(tick)


Code Block
languagexml
titleInput
{% assign 
my_array
thisIsAString = '
alan,catherine,tom,erin,mark' | split: ','
this is a string' %}
{
%
{ 
for
thisIsAString 
user in my_array %} {{ user
| upcase }}
{%
 
endfor %}


Code Block
languagexml
titleOutput
alan
THIS 
catherine
IS 
tom erin mark
A STRING


NumberNumbers include floats and integers:(tick)


Code Block
languagexml
titleInput
{% assign 
my_array
thisIsAnInteger = 
'alan,catherine,tom,erin,mark' | split: ','
10 %}
{{
my_array[2]
 thisIsAnInteger | minus: 2 }} 


Code Block
languagexml
titleOutput
tom
8
 



Code Block
 
language

...

xml

...

OperatorMeaningWorkSyntaxcommentAny text within the opening and closing comment blocks will not be output, and any Liquid code within will not be executed(tick)  
title

Comment

Input
{% assign thisIsAFloat = 10.234 %}
{{ thisIsAFloat  | minus: 2 }} 


Code Block
languagexml
titleOutput
8.23400020599365


Boolean
(tick)


Code Block
languagexml
Text 1 {% comment %} Text 2 {% endcomment %}
 
titleInput
{% assign thisIsTrue = true %}
{{ thisIsTrue }}


Code Block
languagexml
titleOutput
Text 1
 OperatorMeaningWorkSyntaxifExecutes a block of code only if a certain condition is 

Control flow

true
(tick)



Code Block
languagexml
titleInput
{% assign 
c1
thisIsFalse = 
dynamicfields.age| evalinteger: 'equalTo', '10'
true %}
{{
% if c1 == true %} 10 years old {% endif %
 thisIsFalse }}


Code Block
languagexml
titleOutput
10 years old 
Code Block
languagexml
{% if dynamicfields.name == 'alan' %} alan
false


Nil

Nil is a special empty value that is returned when the Liquid code has no results. It is not a string with the characters “nil”.

Nil is treated as false in the conditions of if blocks and other Liquid tags that check the truthfulness of a statement.

(tick)


Code Block
languagexml
titleInput
{% if user %}
  Hello user!
{% endif %}


Code Block
languagexml
titleOutput
alancode
 Hello user!



Code Block
unlessExecutes a block of code only if a certain condition is not match(tick)
languagexml
titleInput
{% 
assign
unless 
c1
user 
= dynamicfields.age| evalinteger: 'equalTo', '10' %} {% unless c1 == true %} Not 10 years old {%
%}
  Hello user!
{% endunless %}


Code Block
languagexml
titleOutput
Not 10 years old
 Hello user!


ArrayArrays hold lists of variables of any type.(tick)


Code Block
languagexml
titleInput
{% 
unless dynamicfields.name
assign my_array =
=
 'alan,catherine,tom,erin,mark' 
%}
| split: 
alan
',' 
{
%}
endunless %
{{ my_array.first }}
{{ my_array.last }}


Code Block
languagexml
titleOutput
alan
elsif/elseAdds more conditions within an if or unless block.(tick)
mark



Code Block
languagexml
titleInput
{% 
if dynamicfields.name =
assign my_array = 'alan,catherine,tom,erin,mark' | split: ',' %}

alan
{% 
elsif
for 
dynamicfields.name == 'tom'
user in my_array %}
tom
 {
%
{ 
else
user 
%
}}
catherine {
{% 
endif
alan
Code Block
languagexml
titleoutput if name is mickey
tom
endfor %}


Code Block
languagexml
title
output if name is goofyCreates a switch statement to compare a variable with different values(tick)code
Output
alan catherine tom erin mark



Code Block
languagexml
title
output for each other name
catherine
case/when
Input
{% 
case dynamicfields.name%} {% when 'alan
assign my_array = 'alan,catherine,tom,erin,mark' | split: ',' %}
This is a alan {% when 'tom' %} This is a tom {% else %} This is not a alan nor a tom. can it be a catherine? {% endcase %}
{{ my_array[2] }}


Code Block
languagexml
titleOutput
tom



TAGS

Comment

OperatorMeaningWorkSyntax
commentAny text within the opening and closing comment blocks will not be output, and any Liquid code within will not be executed(tick)

  

Code Block
languagexml
titleInput
Text 1 {% comment %} Text 2 {% endcomment %}

 

Code Block
languagexml
titleOutput
Text 1

 

Control flow

This is a alan
OperatorMeaningWorkSyntax
if

Executes a block of code only if a certain condition is true

(tick)


Code Block
languagexml
titleInput
{% assign c1 = dynamicfields.age| evalinteger: 'equalTo', '10' %} 
{% if c1 == true %} 
10 years old 
{% endif %}


Code Block
languagexml
title
output if name is goofyThis is a tom
Output
10 years old 



Code Block
languagexml
title
output if name is mickey
Input
{% if dynamicfields.name == 'alan' %} 
alan
{% endif %}


Code Block
languagexml
title
output for each other name
This is not a alan nor a tom. can it be a catherine?

Iteration

For

OperatorMeaningWorkSyntax

for

Repeatedly executes a block of code.
Output
alan 


unlessExecutes a block of code only if a certain condition is not match(tick)


Code Block
language
title
xml
Input
{% assign 
my_array
c1 = 
'alan,catherine,tom,erin,mark'
dynamicfields.age| 
split
evalinteger: 'equalTo', '10' %} 
{% 
for
unless 
user
c1 
in my_array
== true %} 
{{
Not 
user
10 
}}
years old
{% 
endfor
endunless %}


Code Block
languagexml
titleOutput
alan
Not 
catherine
10 
tom erin markbreak

Causes the loop to stop iterating when it encounters the break tag.

(tick)
years old



Code Block
languagexml
titleInput
{% 
assign my_array
unless dynamicfields.name == 'alan
,catherine,tom,erin,mark' | split: ',
' %} 
{% for user in my_array %}

alan
{% 
if user == 'erin' %} {% break
endunless %}


Code Block
languagexml
titleOutput
alan 


elsif/elseAdds more conditions within an if or unless block.(tick)


Code Block
languagexml
titleInput
{% if dynamicfields.name == 'alan' %} 
alan
{% 
else %} {{ user }}
elsif dynamicfields.name == 'tom' %}
tom
{% 
endif
else %}
catherine
{% 
endfor
endif %}


Code Block
languagexml
title
Output
output if name is goofy
alan
catherine tomCauses the loop to skip the current iteration when it encounters the continue tag.
continue


Code Block
languagexml
titleoutput if name is tom
tom


Code Block
languagexml
titleoutput for each other name
catherine


case/whenCreates a switch statement to compare a variable with different values(tick)


Code Block
language
title
xml
Input
{% 
assign my_array = 'alan,catherine,tom,erin,mark' | split: ',
case dynamicfields.name%}
  {% when 'alan' %}
{%
 
for
 
user in my_array %}
   This is a alan
  {% 
if user ==
when '
erin
tom' %}
    
{% continue %}
 This is a tom
  {% else %}
    
{{ user }} {% endif %}
 This is not a alan nor a tom. can it be a catherine?
{% 
endfor
endcase %} 


Code Block
languagexml
title
Output
alan catherine tom mark
limitLimits the loop to the specified number of iterations
output if name is goofy
This is a alan


Code Block
languagexml
titleoutput if name is mickey
This is a tom


Code Block
languagexml
titleoutput for each other name
This is not a alan nor a tom. can it be a catherine?


Iteration

For

OperatorMeaningWorkSyntax

for

Repeatedly executes a block of code.

(tick)


Code Block
languagexml
titleInput
{% assign my_array = 'alan,catherine,tom,erin,mark' | split: ',' %}
{% for user in my_array 
limit:2
%}
 {{ user }}
{% endfor %}


Code Block
languagexml
titleOutput
alan catherine
offsetBegins the loop at the specified index
 tom erin mark


break

Causes the loop to stop iterating when it encounters the break tag.

(tick)


Code Block
languagexml
titleInput
{% assign my_array = 'alan,catherine,tom,erin,mark' | split: ',' %}
{% for user in my_array
offset:2
 %}
 {% if user == 'erin' %}
    {% break %}
  {% else %}
    {{ user }}
  {% endif %}
{% endfor %}


Code Block
languagexml
titleOutput
tom
alan 
erin
catherine 
markDefines a range of numbers to loop through. The range can be defined by both literal and variable numbers
tom

range


continue

Causes the loop to skip the current iteration when it encounters the continue tag.

(tick)


Code Block
languagexml
titleInput
{% assign my_array = 'alan,catherine,tom,erin,mark' | split: ',' %}
{% for 
i
user in 
(3..5)
my_array %}
 
{{ i }}
{% if user == 'erin' %}
    {% 
endfor
continue %}
Code Block
languagexml
titleOutput
3 4 5
Code Block
languagexml

  {% 
assign num = 4
else %}
 
{%
 
for
 
i
 
in (1..num) %
{{ user }}
  {
{
% 
i
endif %}
}

{% endfor %}


Code Block
languagexml
titleOutput
1
alan 
2
catherine 
3
tom 
4
mark
reversedReverses the order of the loop


limitLimits the loop to the specified number of iterations.(tick)


Code Block
languagexml
titleInput
{% assign my_array = 'alan,catherine,tom,erin,mark' | split: ',' %}
{% for user in my_array 
reversed
limit:2 %}
 {{ user }}
{% endfor %}


Code Block
languagexml
titleOutput
mark
alan 
erin tom
catherine
alan OperatorMeaningWorkSyntax

Cycle

Repeatedly executes a block of code

Cycle


offsetBegins the loop at the specified index.(tick)


Code Block
languagexml
titleInput
{% assign my_array = 'alan,catherine,tom,erin,mark' | split: ',' %}
{% for user in my_array offset:2 %}
 {{
%
 
cycle 'first one', 'second one', 'third one' %}
user }}
{% endfor %}


Code Block
languagexml
titleOutput
first
tom 
one second one third one first one second one

Tablerow

OperatorMeaningWorkSyntax

tablerow 

Generates an HTML table. Must be wrapped in opening <table> and closing </table> HTML tags.

 

 

colsDefines how many columns the tables should have.  limitExits the tablerow after a specific index.  offsetStarts the tablerow after a specific index.  rangeDefines a range of numbers to loop through.
erin mark


range

Defines a range of numbers to loop through. The range can be defined by both literal and variable numbers.
 
(tick)
 


Code Block

...

language
Operator
xml
Meaningassign

Creates a new variable

(tick) Code Block
languagexml
title
WorkSyntax
Input
{% 
assign
for 
c1
i 
= 10
in (3..5) %}
{%
 
if
 
c1
{{ 
== 10 %} It is ten!
i }}
{% 
endif
endfor %}


Code Block
languagexml
titleOutput
It
3 
is
4 
ten!
5



Code Block
languagexml
titleInput
{% assign 
c1
num = 
'alan'
4 %}
{% 
if
for 
c1
i 
== 'alan'
in (1..num) %}
  {{ 
It is alan!
i }}
{% 
endif
endfor %}


Code Block
languagexml
titleOutput
It
1 2 
is
3 
alan!
4
capture


reversed
Captures
Reverses the
string inside of the opening and closing tags and assigns it to a variable. Variables created through {% capture %} are strings
order of the loop.(tick)


Code Block
languagexml
titleInput
{% assign 
name
my_array =
dynamicfields.name
 'alan,catherine,tom,erin,mark' | split: ',' %}
{% for 
assign
user 
surname
in 
= dynamicfields.surname
my_array reversed %}
 {
% capture about_me %} I am {{ name
{ user }}
{
{
surname }} and my favorite food is pizza. {
% 
endcapture
endfor %
} {{ about_me
}
}


Code Block
languagexml
title
output
Output
I
mark 
am
erin 
Catherine
tom 
Martin
catherine 
and my favorite food is pizza.incrementCreates a new number variable, and increases its value by one every time it is called. The initial value is 0.(error) decrementCreates a new number variable, and decreases its value by one every time it is called. The initial value is -1.(error) 

Filters

TBD

OperatorMeaningWorkSyntaxabs

Returns the absolute value of a number.

(error) append

Concatenates two strings and returns the concatenated value.

(tick)
Code Block
titleInput
{{ "Hello " | append: "Carl" }}
Code Block
titleOutput
Hello Carl

 

 

Code Block
titleInput
{{ "Welcome" | append: dynamicfields.name }}
Code Block
titleOutput
Welcome Luke 
Code Block
titleInput
{{ dynamicfields.name | append: " welcome!"}}
Code Block
titleOutput
Luke welcome!
at_least

Limits a number to a minimum value.

(error) at_most

Limits a number to a maximum value.

(error) capitalize

Makes the first character of a string capitalized.

(tick)
Code Block
titleInput
{{ "my great title" | capitalize }}
Code Block
titleOutput
My great title

 

 

Code Block
titleInput
{{ dynamicfields.nome | capitalize }}
Code Block
titleOutput
Luke
ceil

Rounds the input up to the nearest whole number. Liquid tries to convert the input to a number before the filter is applied.

(error) compact

Removes any nil values from an array.

  concat

Concatenates (joins together) multiple arrays. The resulting array contains all the items from the input arrays.

(error) dateConverts a timestamp into another date format. The format for this syntax is the same as strftime. The input uses the same format as Ruby’s Time.parse.  defaultAllows you to specify a fallback in case a value doesn’t exist. defaultwill show its value if the left side is nilfalse, or empty.(error) divided_byDivides a number by the specified
alan 


Cycle

OperatorMeaningWorkSyntax

Cycle

Repeatedly executes a block of code.

(tick)


Code Block
languagexml
titleInput
{% assign my_array = 'alan,catherine,tom,erin,mark' | split: ',' %}
{% for user in my_array %}
 {% cycle 'first one', 'second one', 'third one' %} 
{% endfor %}


Code Block
languagexml
titleOutput
first one second one third one first one second one



Variable

OperatorMeaningWorkSyntax
assign

Creates a new variable

(tick)


Code Block
languagexml
titleInput
{% assign c1 = 10 %}
{% if c1 == 10 %} 
    It is ten!
{% endif %}


Code Block
languagexml
titleOutput
It is ten!



Code Block
languagexml
titleInput
{% assign c1 = 'alan' %}
{% if c1 == 'alan' %} 
   It is alan!
{% endif %}


Code Block
languagexml
titleOutput
It is alan!


captureCaptures the string inside of the opening and closing tags and assigns it to a variable. Variables created through {% capture %} are strings.(tick)


Code Block
languagexml
titleInput
{% assign name = dynamicfields.name %}
{% assign surname = dynamicfields.surname %}

{% capture about_me %}
I am {{ name }} {{ surname }} and my favorite food is pizza.
{% endcapture %}

{{ about_me }}


Code Block
languagexml
titleoutput
I am Catherine Martin and my favorite food is pizza.


incrementCreates a new number variable, and increases its value by one every time it is called. The initial value is 0.(error)
decrementCreates a new number variable, and decreases its value by one every time it is called. The initial value is -1.(error)

Filters


...

OperatorMeaningWorkSyntax
abs

Returns the absolute value of a number.

(error)
append

Concatenates two strings and returns the concatenated value.

(tick)


Code Block
titleInput
{{ "Hello " | append: "Carl" }}


Code Block
titleOutput
Hello Carl



Code Block
titleInput
{{ "Welcome" | append: dynamicfields.name }}


Code Block
titleOutput
Welcome Luke 



Code Block
titleInput
{{ dynamicfields.name | append: " welcome!"}}


Code Block
titleOutput
Luke welcome!


at_least

Limits a number to a minimum value.

(error)
at_most

Limits a number to a maximum value.

(error)
capitalize

Makes the first character of a string capitalized.

(tick)


Code Block
titleInput
{{ "my great title" | capitalize }}


Code Block
titleOutput
My great title



Code Block
titleInput
{{ dynamicfields.nome | capitalize }}


Code Block
titleOutput
Luke


ceil

Rounds the input up to the nearest whole number. Liquid tries to convert the input to a number before the filter is applied.

(error)
compact

Removes any nil values from an array.



concat

Concatenates (joins together) multiple arrays. The resulting array contains all the items from the input arrays.

(error)
dateConverts a timestamp into another date format. The format for this syntax is the same as strftime. The input uses the same format as Ruby’s Time.parse.

defaultAllows you to specify a fallback in case a value doesn’t exist. defaultwill show its value if the left side is nilfalse, or empty.(error)
divided_by

Divides a number by the specified number.

(warning)

Does not work on dynamicfields.


Code Block
titleInput
{{ 16 | divided_by: 4 }}


Code Block
titleOutput
4



Code Block
titleInput
{{ subTotal| divided_by: 4 }}


Code Block
titleOutput
100


downcase

Makes each character in a string lowercase. It does not affect strings that are already all lowercase.

(tick)


Code Block
titleInput
{{ "Parker Moore" | downcase }}


Code Block
titleOutput
parker moore



Code Block
titleInput
{{ dynamicfields.nome | downcase}}


Code Block
titleOutput
luke


escape

Escapes a string by replacing characters with escape sequences (so that the string can be used in a URL, for example). It doesn’t change strings that don’t have anything to escape.

(error)
escape_once

Escapes a string without changing existing escaped entities. It doesn’t change strings that don’t have anything to escape.

(error)
first

Returns the first item of an array.


Assuming the userid dynamicfield contains "1,2,3,4,5".

Code Block
titleInput
{% assign my_array = dynamicfields.userid | split: "," %}
{{ my_array.first }}


Code Block
titleOutput



Code Block
titleInput
{% assign my_array = "apples, oranges, peaches, plums" | split: ", " %}
{{ my_array.first }}


Code Block
titleOutput
apples


floor

Rounds a number down to the nearest whole number. Liquid tries to convert the input to a number before the filter is applied.

(error)


join

Combines the items in an array into a single string using the argument as a separator.

(tick)

Assuming the userid dynamicfield contains "1,2,3,4,5".


Code Block
titleInput
{% assign my_array = dynamicfields.userid | split: "," %}
{{ my_array | join: " and " }} 


Code Block
titleOutput
1 and 2 and 3 and 4 and 5



Code Block
titleInput
{% assign beatles = "John, Paul, George, Ringo" | split: ", " %}
{{ beatles | join: " and " }} 


Code Block
titleOutput
John and Paul and George and Ringo


last

Returns the last item of an array.

(tick)

Assuming the userid dynamicfield contains "1,2,3,4,5".

Code Block
titleInput
{% assign my_array = dynamicfields.userid | split: "," %}
{{ my_array.last}}


Code Block
titleOutput
5



Code Block
titleInput
{% assign my_array = "apples, oranges, peaches, plums" | split: ", " %}

{{ my_array.last }}


Code Block
titleOutput
plums


lstrip

Removes all whitespaces (tabs, spaces, and newlines) from the beginning of a string. The filter does not affect spaces between words.

(error)
map

Creates an array of values by extracting the values of a named property from another object.

(tick)

Assuming the products contains:


Code Block
languagejava
{
	"products": [{
		"title": "Product 1",
		"price": 100
	}, {
		"title": "Product 2",
		"price": 200
	}, {
		"title": "Product 3",
		"price": 300
	}]
}



Code Block
titleInput
{% assign all_titles = products | map: "title" %}

{% for item in all_titles %}
{{ item }}
{% endfor %}


Code Block
titleOutput
Product 1
Product 2
Product 3


minus

Subtracts a number from another number.

(warning)

Does not work on dynamicfields.

 

Code Block
titleInput
{{ 
16
4 | 
divided_by
minus: 
4
2 }}
 


Code Block
titleOutput
4

 

2



Code Block
titleInput
{{ 
subTotal
SubTotal | 
divided_by
minus: 
4
100 }}


Code Block
titleOutput
100(tick)
900
downcase

Makes each character in a string lowercase. It has no effect on strings which are already all lowercase.


modulo

Returns the remainder of a division operation.

(warning)

Does not work on dynamicfields.


Code Block
titleInput
{{ 
"Parker
3 
Moore"
| 
|
modulo: 
downcase

 

 

2 }}


Code Block
titleOutput
parker moore
1



Code Block
titleInput
{{ 
dynamicfields.nome
SubTotal | 
downcase
modulo: 6}}


Code Block
titleOutput
luke
escapeEscapes a string by replacing characters with escape sequences (so that the string can be used in a URL, for example). It doesn’t change strings that don’t have anything to escape
4


newline_to_br

Replaces every newline (\n) with an HTML line break (<br>).

(error)
 escape_once

Escapes a string without changing existing escaped entities. It doesn’t change strings that don’t have anything to escape.

(error) first

Returns the first item of an array.

 Assuming the userid dynamicfield contains "1,2,3,4,5"

plus

Adds a number to another number.

(tick)

Assuming the TotalIncome dynamic field contains 500.

Code Block
titleInput
{
% assign my_array =
{ dynamicfields.
userid
TotalIncome| 
split: "," %} {{ my_array.first 
plus: 2 }}


Code Block
titleOutput

 

502



Code Block
titleInput
{{
% assign my_array = "apples, oranges, peaches, plums" | split: ", " %} {{ my_array.first
 5| plus: 2 }}


Code Block
titleOutput
apples
floor

Rounds a number down to the nearest whole number. Liquid tries to convert the input to a number before the filter is applied.

(error)

 

join

Combines the items in an array into a single string using the argument as a separator.

(tick)Assuming the userid dynamicfield contains "1,2,3,4,5".

 

7


prepend

Adds the specified string to the beginning of another string.

(tick)


Code Block
titleInput
{
%
{ 
assign my_array = dynamicfields.userid | split: "," %} {{ my_array | join: " and
"apples, oranges, and bananas" | prepend: "Some fruit: " }}


Code Block
titleOutput
Some fruit: apples, oranges, and bananas



Code Block
titleInput
{{ dynamicfields.Name| prepend: "Hello " }}


Code Block
titleOutput
1 and 2 and 3 and 4 and 5

 

 

Hello Luke




Code Block
titleInput
{
% assign beatles = "John, Paul, George, Ringo" | split: ", " %} {{ beatles | join: " and " }} 
{ dynamicfields.Name| prepend: dynamicfields.Surname}}


Code Block
titleOutput
Luke Skywalker




Code Block
titleInput
{{ "Welcome" | prepend: dynamicfields.Name }}


Code Block
titleOutput
John and Paul and George and Ringo
last

Returns the last item of an array.

(tick)Assuming the userid dynamicfield contains "1,2,3,4,5".
Welcome Luke


remove

Removes every occurrence of the specified substring from a string.

(tick)


Code Block
titleInput
{{ "I strained to see the train through the rain" | remove: "rain" }}


Code Block
title
Input{% assign my_array = dynamicfields.userid | split: "," %} {{ my_array.last
Output
I sted to see the t through the 




Code Block
titleInput
{{ dynamicfields.Name| remove: "uk"}}


Code Block
titleOutput
Le



Code Block
titleInput
{{"Luke Skywalker" | remove: dynamicfields.Name}}


Code Block
titleOutput
5

 

 
Skywalker


remove_first

Removes only the first occurrence of the specified substring from a string.

(tick)


Code Block
titleInput
{{
% assign my_array = "apples, oranges, peaches, plums
 "I strained to see the train through the rain" | 
split
remove_first: "
, " %} {{ my_array.last }}
Code Block
titleOutput
plums
lstrip

Removes all whitespaces (tabs, spaces, and newlines) from the beginning of a string. The filter does not affect spaces between words.

(error)TODO: dovrebbe funzionaremap

Creates an array of values by extracting the values of a named property from another object.

 

 

minus

Subtracts a number from another number.

(warning)

Does not work on dynamicfields.

rain" }}


Code Block
titleOutput
I sted to see the train through the rain


replace

Replaces every occurrence of an argument in a string with the second argument.

(tick)


Code Block
titleInput
{{
4
 "Take my protein pills and put my helmet on" | 
minus
replace:
 "my", "your" }}


Code Block
titleOutput
2

 

 

Take your protein pills and put your helmet on


replace_first

Replaces only the first occurrence of the first argument is a string with the second argument.

(tick)


Code Block
titleInput
{
{ SubTotal | minus: 100
% assign my_string = "Take my protein pills and put my helmet on" %}
{{ my_string | replace_first: "my", "your" }}


Code Block
titleOutput
900
modulo

Returns the remainder of a division operation.

(warning)

Does not work on dynamicfields.

 

Code Block
titleInput
{{ 3 | modulo: 2 }}
Code Block
titleOutput
1

 

 

Take your protein pills and put my helmet on


reverse

Reverses the order of the items in an array. reverse cannot reverse a string.

(error)
round

Rounds an input number to the nearest integer or, if a number is specified as an argument, to that number of decimal places.

(tick)

Does not work on dynamicfields.



Code Block
titleInput
{{ 
SubTotal
1.2 | 
modulo:
round 
6
}}


Code Block
titleOutput
4
newline_to_br

Replaces every newline (\n) with an HTML line break (<br>).

(error) plus

Adds a number to another number.

(tick)Assuming the TotalIncome dynamic field contains 500.
1


rstrip

Removes all whitespace (tabs, spaces, and newlines) from the right side of a string.

(error)
size

Returns the number of characters in a string or the number of items in an array. size can also be used with dot notation (for example, {{ my_string.size }}). This allows you to use size inside tags such as conditionals.

(tick)


Code Block
titleInput
{{ 
dynamicfields.TotalIncome| plus: 2 }}
Code Block
titleOutput
502

 

 

 

Code Block
titleInput
{{ 5| plus: 2
"Ground control to Major Tom." | size }}


Code Block
7(tick)
title
prepend

Adds the specified string to the beginning of another string.

Output
28



Code Block
titleInput
{
{
% assign my_array = "apples, oranges, 
and
peaches, 
bananas
plums" | 
prepend
split: "
Some fruit: "
, " %}

{{ my_array | size }}


Code Block
titleOutput
Some fruit: apples, oranges, and bananas

 

 
4


slice

Returns a substring of 1 character beginning at the index specified by the argument passed in. An optional second argument specifies the length of the substring to be returned.

String indices are numbered starting from 0.

(tick)


Code Block
titleInput
{{
dynamicfields.Name
 "Liquid" | 
prepend
slice: 
"Hello " 
0 }}


Code Block
titleOutput
Hello Luke

 

 

L



Assuming title contains "Return to the future"

Code Block
titleInput
{{title 
dynamicfields.Name
| 
prepend
slice: 
dynamicfields.Surname
0}}


Code Block
titleOutput
Luke Skywalker

 

 

 

R



Code Block
titleInput
{{ 
"Welcome"
dynamicfields.title| 
prepend
slice: 
dynamicfields.Name
0 }}


Code Block
titleOutuput
R
Output
Welcome Luke
remove

Removes every occurrence of the specified substring from a string.

 


sort

Sorts items in an array by a property of an item in the array. The order of the sorted array is case-sensitive.

(warning)

Same behavior of the sort_natural filter.


Code Block
titleInput
{
{
% 
"I strained to see the train through the rain" | remove: "rain" }}
Code Block
titleOutput
I sted to see the t through the 

 

 

 

Code Block
titleInput
{{ dynamicfields.Name| remove: "uk"
assign my_array = "zebra, octopus, giraffe, Sally Snake" | split: ", " %}

{{ my_array | sort_natural | join: ", " }}


Code Block
titleOutput
Le

 

 

Code Block
titleInput
{{"Luke Skywalker" | remove: dynamicfields.Name}}
Code Block
titleOutput
Skywalker
remove_firstRemoves only the first occurrence of the specified substring from a string
giraffe, octopus, Sally Snake, zebra


sort_naturalSorts items in an array by a property of an item in the array.(error)
splitDivides an input string into an array using the argument as a separator. split is commonly used to convert comma-separated items from a string to an array.(tick)


Code Block
titleInput
{
{ "I strained to see the train through the rain" | remove_first: "rain" }
% assign beatles = "John, Paul, George, Ringo" | split: ", " %}
{% for member in beatles %}
{{ member }}
{% endfor %}


Code Block
titleOutput
I
John
sted

to
Paul
see

the
George
train

through the rainreplace

Replaces every occurrence of an argument in a string with the second argument.

(tick)
Ringo


Assuming the dynamic field albumid contains "1,2,3,4,5"

Code Block
titleInput
{
{ "Take my protein pills and put my helmet on"
% assign ids= dynamicfields.albumid | 
replace
split: 
"my
",
"your
" 
}}
Code Block
titleOutput
Take your protein pills and put your helmet on

 

 

TODO: aggiungere esempi con campi dinamici!

replace_first

Replaces only the first occurrence of the first argument in a string with the second argument.

(tick) reverse

Reverses the order of the items in an array. reverse cannot reverse a string.

(error) round

Rounds an input number to the nearest integer or, if a number is specified as an argument, to that number of decimal places.

(tick) rstrip
%}
{% for id in ids%}
{{ id }}
{% endfor %}


Code Block
titleOutput
1
2
3
4
5


strip

Removes all whitespace (tabs, spaces, and

newlines) from the right side of  

newlines) from both the left and right sides of a string. It does not affect spaces between words.

(error)
strip_html

Removes any HTML tags from a string.

(tick)
(error)TODO: dovrebbe funzionaresize

Returns the number of characters in a string or the number of items in an array. size can also be used with dot notation (for example, {{ my_string.size }}). This allows you to use size inside tags such as conditionals.

(tick) slice

Returns a substring of 1 character beginning at the index specified by the argument passed in. An optional second argument specifies the length of the substring to be returned.

String indices are numbered starting from 0.

(tick) sort

Sorts items in an array by a property of an item in the array. The order of the sorted array is case-sensitive.

(warning) sort_naturalSorts items in an array by a property of an item in the array.  splitDivides an input string into an array using the argument as a separator. split is commonly used to convert comma-separated items from a string to an array.(tick) strip

Removes all whitespace (tabs, spaces, and newlines) from both the left and right side of a string. It does not affect spaces between words.

(error)TODO: dovrebbe funzionarestrip_html

Removes any HTML tags from a string.

  strip_newlines

Removes any newline characters (line breaks) from a string.

  times

Multiplies a number by another number.

(warning) truncate

truncate shortens a string down to the number of characters passed as a parameter. If the number of characters specified is less than the length of the string, an ellipsis (…) is appended to the string and is included in the character count.

(tick)


Code Block
titleInput
{{ "Have <em>you</em> read <strong>Ulysses</strong>?" | strip_html }}


Code Block
titleOutput
Have you read Ulysses?


strip_newlines

Removes any newline characters (line breaks) from a string.

(error)
times

Multiplies a number by another number.

(warning)

Does not work on dynamicfields.


Code Block
titleInput
{{ 24 | times: 7 }}


Code Block
titleOutput
168


truncate

truncate shortens a string down to the number of characters passed as a parameter. If the number of characters specified is less than the length of the string, an ellipsis (…) is appended to the string and is included in the character count.

(tick)


Code Block
titleInput
{{ "Ground control to Major Tom." | truncate: 20 }}


Code Block
titleOutput
Ground control to...



Code Block
titleInput
{{ "Ground control to Major Tom." | truncate: 25, ", and so on" }}


Code Block
titleOutput
Ground control, and so on


truncatewords

Shortens a string down to the number of words passed as the argument. If the specified number of words is less than the number of words in the string, an ellipsis (…) is appended to the string.

(warning)
(error)
TODO: dovrebbe funzionare

uniq

Removes any duplicate elements in an array.

(error)
 

upcase

Makes each character in a string uppercase. It

has no effect on strings which

does not affect strings that are already all uppercase.

(tick)


Code Block
titleInput
{{ dynamicfields.name | upcase }}


Code Block
titleOutput
LUKE


url_decode

Decodes a string that has been encoded as a URL or by url_encode.

(error)
 

url_encode

Converts any URL-unsafe characters in a string into percent-encoded characters.

(error)