...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
Operators
...
It is possible use this operator with dynamic fields 'as is' only to compare strings.
Code Block |
---|
|
{% 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 |
---|
|
{% assign c1 = dynamicfields.name| evaltext: 'equalTo', 'Jennifer' %} {% if c1 == true %} Text {% endif %} |
Code Block |
---|
|
{% 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
Operator | Meaning | Work | Syntax |
---|
== | equals | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png)
| This operator can be used with dynamic fields 'as is' only to compare strings. Code Block |
---|
| {% 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 |
---|
| {% assign c1 = dynamicfields.name| evaltext: ' |
|
otherThanequalTo', 'Jennifer' %} {% if c1 == true %} Text {% endif %} |
Code Block |
---|
| {% assign c1 = dynamicfields.age | evalinteger: ' |
|
otherThanequalTo', '8' %} {% if c1 == true %} Text {% endif %} |
|
> | greater than |
!= | does not equal | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) | It is possible to use this operator with dynamic fields 'as is' only to compare strings. Code Block |
---|
| {% 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 |
---|
| {% assign c1 = dynamicfields.name| evaltext: ' |
|
moreThanotherThan', 'Jennifer' %} {% if c1 == true %} Text {% endif %} |
Code Block |
---|
| {% assign c1 = dynamicfields.age | evalinteger: ' |
|
moreThanotherThan', '8' %} {% if c1 == true %} Text {% endif %} |
|
<less greater than | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) | It is possible to use this operator with dynamic fields 'as is' only to compare strings. Code Block |
---|
| {% 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 |
---|
| {% assign c1 = dynamicfields.name| evaltext: ' |
|
lessThanmoreThan', 'Jennifer' %} {% if c1 == true %} Text {% endif %} |
Code Block |
---|
| {% assign c1 = dynamicfields.age | evalinteger: ' |
|
lessThanmoreThan', '8' %} {% if c1 == true %} Text {% endif %} |
|
>=greater or equal to | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) | It is possible to use this operator with dynamic fields 'as is' only to compare strings. Code Block |
---|
| {% 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 |
---|
| {% assign c1 = dynamicfields.name| evaltext: ' |
|
equalOrMoreThanlessThan', 'Jennifer' %} {% if c1 == true %} Text {% endif %} |
Code Block |
---|
| {% assign c1 = dynamicfields.age | evalinteger: ' |
|
equalOrMoreThanlessThan', '8' %} {% if c1 == true %} Text {% endif %} |
|
<less greater than or equal to | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) | It is possible to use this operator with dynamic fields 'as is' only to compare strings. Code Block |
---|
| {% 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 |
---|
| {% assign c1 = dynamicfields.name| evaltext: ' |
|
equalOrLessThanequalOrMoreThan', 'Jennifer' %} {% if c1 == true %} Text {% endif %} |
Code Block |
---|
| {% assign c1 = dynamicfields.age | evalinteger: ' |
|
equalOrLessThanequalOrMoreThan', '8' %} {% if c1 == true %} Text {% endif %} |
|
orlogical less than or equal to | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) |
Code Block |
---|
|
{It is possible to use this operator with dynamic fields 'as is' only to compare strings. Code Block |
---|
| {% if dynamicfields.name |
|
=or%}
alan
{% elsif dynamicfields. |
|
age=child
is alan or a child
It is an adult alan or another adult
Code Block |
languageand | logical and | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) | 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: |
if==alan and dynamicfields.age == 'childalanisa child
{% elseit is an adult
contains | checks for the presence of a substring inside a string |
ifassign c1 = dynamicfields. |
|
namecontains 'oof| evalinteger: 'equalOrLessThan', '8' %} {% |
|
couldbealan?{ else %
surely isn't alan
...
String | Declare a string by wrapping a variable’s value in single quotes: | Type | Meaning | Work | Syntax |
---|
logical or | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) | |
assignthisIsAStringdynamicfields.name == 'alan' |
|
this is a string or dynamicfields.age == 'child' %} |
|
{{thisIsAString|upcase}} Code Block |
---|
|
THIS IS A STRING |
Number | Numbers include floats and integers: | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) | Code Block |
---|
|
{% assign thisIsAnInteger = 10 %}
{{ thisIsAnInteger | minus: 2 }} |
Code Block |
---|
|
8a child
{% else %}
It is an adult alan or another adult
{% endif %} |
|
and | logical and | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) | |
assignthisIsAFloat 10.234= 'alan' and dynamicfields.age == 'child' %} |
|
{{ thisIsAFloat | minus: 2 }} Code Block |
---|
|
8.23400020599365 |
Boolean |
alan is a child
{% else %}
it is an adult
{% endif %} |
|
contains | checks for the presence of a substring inside a string | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) | |
assignthisIsTrue=true{{thisIsTrue }} Code Block |
---|
|
truebe alan?
{% else %}
surely isn't alan
{% endif %} |
|
Types
Type | Meaning | Work | Syntax |
---|
String | Declare a string by wrapping a variable’s value in single quotes: | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) | |
thisIsFalsetrue'this is a string' %}
{{ thisIsAString | |
|
thisIsFalseNil is treated as false in the conditions of if
blocks and other Liquid tags that check the truthfulness of a statement.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”.
|
Number | Numbers include floats and integers: | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) |
Code Block |
---|
| {% assign thisIsAnInteger |
|
ifuserHellouser!
{% endif %} unlessuser%}
Hello user!
{% endunless %}Array | Arrays hold lists of variables of any type. | = 10.234 %}
{{ thisIsAFloat | minus: 2 }} |
|
Hello user! |
|
Boolean |
| ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) | |
my_array'alan,catherine,tom,erin,mark' | split: ','my_array.first
{{ my_array.last }}alan
markmy_array'alan,catherine,tom,erin,mark' | split: ',' % for user in my_array %}
{user
{% endfor %}alan catherine tom erin mark |
Code Block |
---|
language | xml |
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)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) | |
assignmy_array = 'alan,catherine,tom,erin,mark' | split: ',' %}
{{ my_array[2] }}user %}
Hello user!
{% endif %} |
|
tom |
TAGS
Operator | Meaning | Work | Syntax |
---|
comment | Any text within the opening and closing comment blocks will not be output, and any Liquid code within will not be executed | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) |
Code Block |
---|
|
Text 1 {% comment %} Text 2 {% endcomment %} |
Code Block |
---|
| {% unless user %}
Hello user!
{% endunless %} |
|
Text1
Control flow
Operator | Meaning | Work | Syntax |
---|
if | Executes a block of code only if a certain condition is true | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) | Code Block |
---|
language | xmlArray | Arrays hold lists of variables of any type. | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) | |
c1dynamicfields.age'alan,catherine,tom,erin,mark' | |
|
evalintegerequalTo' 10'
%if c1 == true %}
10 years old
{% endif %my_array.first }}
{{ my_array.last }} |
|
10 years old if dynamicfields.name= 'alan,catherine,tom,erin,mark' | split: ',' %}
{% for user |
|
alanin my_array %}
{{ user }}
{% |
|
endifcode
Code Block |
---|
| alan catherine tom erin mark |
|
unless | Executes a block of code only if a certain condition is not match | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) | c1dynamicfields.age| evalinteger: 'equalTo', '10'alan,catherine,tom,erin,mark' | split: ',' %}
|
|
% unless c1 == true %}
Not 10 years old
{% endunless %Not 10 years old |
Code Block |
---|
|
{% unless dynamicfields.name == 'alan' %}
alan
{% endunless %} |
TAGS
Operator | Meaning | Work | Syntax |
---|
comment | Any text within the opening and closing comment blocks will not be output, and any Liquid code within will not be executed | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) | Code Block |
---|
| Text 1 {% comment %} Text 2 {% endcomment %} |
|
alan |
elsif/else | Adds more conditions within an if
or unless
block.Control flow
Operator | Meaning | Work | Syntax |
---|
if | Executes a block of code only if a certain condition is true | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) | |
ifassign c1 = dynamicfields. |
|
name ==age| evalinteger: 'equalTo', ' |
|
alan alanelsifdynamicfields.name'tom'tom{%else%}catherineoutput if name is goofy | alanoutput if name is mickey | tomcatherine |
case/when | Creates a switch statement to compare a variable with different values{% if dynamicfields.name == 'alan' %}
alan
{% endif %} |
|
output for each other name | |
unless | Executes a block of code only if a certain condition is not match | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) | |
casename%} {% when 'alan'equalTo', '10' %}
{% unless c1 |
|
This is a alan
== true %}
Not 10 years old
{% |
|
when 'tom'
Code Block |
---|
| Not 10 years old |
Code Block |
---|
| {% unless dynamicfields.name |
|
This is a tom
{% else This is not a nor a tom. can it be a catherine?
endcase This is a alan |
Code Block |
---|
language | xml |
---|
title | output if name is mickey |
---|
|
This is a tomoutput if name is goofy | |
elsif/else | Adds more conditions within an if or unless block. | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) | |
output for each other name | This is not a alan nor a tom. can it be a catherine? |
Iteration
For
Operator | Meaning | Work | Syntax |
---|
for | Repeatedly executes a block of code. | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) | Code Block |
---|
|
{% assign my_array = 'alan,catherine,tom,erin,mark' | split: ',' %}
{% for user in my_array %}
{{ user }}
{% endfor %}alan catherine tom erin mark |
break | Causes the loop to stop iterating when it encounters the break tag. | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png)
| {% if dynamicfields.name == 'alan' %}
alan
{% elsif dynamicfields.name == 'tom' %}
tom
{% else %}
catherine
{% endif %} |
Code Block |
---|
language | xml |
---|
title | output if name is goofy |
---|
| alan |
Code Block |
---|
language | xml |
---|
title | output if name is tom |
---|
| tom |
Code Block |
---|
language | xml |
---|
title | output for each other name |
---|
| catherine |
|
case/when | Creates a switch statement to compare a variable with different values | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) |
Code Block |
---|
| {% case dynamicfields.name%}
{% when 'alan' %}
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 %} |
|
Output |
Code Block |
---|
language | xml |
---|
title | output if name is mickey |
---|
| This is a tom |
|
{% assign my_array = 'alan,catherine,tom,erin,mark' | split: ',' %}
{% for user in my_array %}
{% if user == 'erin' %}
{% break %}
{% else %}
title | output for each other name |
---|
| This is not a alan nor a tom. can it be a catherine? |
|
Iteration
For
Operator | Meaning | Work | Syntax |
---|
for | Repeatedly executes a block of code. | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) |
Code Block |
---|
| {% assign my_array = 'alan,catherine,tom,erin,mark' | split: ',' %}
{% for user in my_array %}
{{ user }}
|
|
% endif }{%
Code Block |
---|
| alan catherine tom |
|
continue skip the current iteration stop iterating when it encounters the |
continue
break tag.
| ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) |
Code Block |
---|
| {% assign my_array = 'alan,catherine,tom,erin,mark' | split: ',' %}
{% for user in my_array %}
{% if user == 'erin' %}
{% |
|
continuebreak %}
{% else %}
{{ user }}
{% endif %}
{% endfor %} |
Code Block |
---|
| alan catherine tom |
|
marklimitLimits the specified number of iterationsskip the current iteration when it encounters the continue tag. | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) |
Code Block |
---|
| {% assign my_array = 'alan,catherine,tom,erin,mark' | split: ',' %}
{% for user in my_array |
|
limit:2%}
{% if user == 'erin' %}
{% continue %}
{% else %}
{{ user }}
{% |
|
endfor
Code Block |
---|
| alan catherine tom mark |
|
offsetBegins at indexnumber of iterations. | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) |
Code Block |
---|
| {% assign my_array = 'alan,catherine,tom,erin,mark' | split: ',' %}
{% for user in my_array |
|
offsetlimit:2 %}
{{ user }}
{% endfor %} |
|
tomerin markDefines a range of numbers to loop through. The range can be defined by both literal and variable numbers.range | offset | Begins the loop at the specified index. | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) | |
foriin (3..5) %}
{{ i= 'alan,catherine,tom,erin,mark' | split: ',' %}
{% for user in my_array offset:2 %}
{{ user }}
{% endfor %} |
|
34 5 |
range | Defines a range of numbers to loop through. The range can be defined by both literal and variable numbers. | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) | |
{% assign num = 4 %}
1num5) %}
{{ i }}
{% endfor %} |
|
1 2 reversed |
Code Block |
---|
| {% assign num = 4 %}
{% for i in (1..num) %}
{{ i }}
{% endfor %} |
|
reversed | Reverses the order of the loop. | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) |
Code Block |
---|
| {% assign my_array = 'alan,catherine,tom,erin,mark' | split: ',' %}
{% for user in my_array reversed %}
{{ user }}
{% endfor %} |
Code Block |
---|
| mark erin tom catherine alan |
|
Cycle
Operator | Meaning | Work | Syntax |
---|
Cycle | Repeatedly executes a block of code. | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) |
Code Block |
---|
| {% assign my_array = 'alan,catherine,tom,erin,mark' | split: ',' %}
{% for user in my_array %}
{% cycle 'first one', 'second one', 'third one' %}
{% endfor %} |
Code Block |
---|
| first one second one third one first one second one |
|
Variable
Operator | Meaning | Work | Syntax |
---|
assign | Creates a new variable | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) |
Code Block |
---|
| {% assign c1 = 10 %}
{% if c1 == 10 %}
It is ten!
{% endif %} |
|
{ | {% assign c1 = 'alan' %}
{% if c1 == 'alan' %}
It is alan!
{% endif %} |
|
capture | Captures the string inside of the opening and closing tags and assigns it to a variable. Variables created through {% capture %} are strings. | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) |
Code Block |
---|
| {% 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 |
---|
| I am Catherine Martin and my favorite food is pizza. |
|
increment | Creates a new number variable, and increases its value by one every time it is called. The initial value is 0. | ![(error)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/error.png) |
|
|
decrement | Creates a new number variable, and decreases its value by one every time it is called. The initial value is -1. | ![(error)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/error.png) |
Filters
...
...
Operator | Meaning | Work | Syntax |
---|
abs | Returns the absolute value of a number. | ![(error)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/error.png) |
|
|
append | Concatenates two strings and returns the concatenated value. | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) |
Code Block |
---|
| {{ "Hello " | append: "Carl" }}
|
|
Code Block |
---|
| {{ "Welcome" | append: dynamicfields.name }} |
Code Block |
---|
| {{ dynamicfields.name | append: " welcome!"}} |
|
at_least | Limits a number to a minimum value. | ![(error)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/error.png) |
|
|
at_most | Limits a number to a maximum value. | ![(error)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/error.png) |
|
|
capitalize | Makes the first character of a string capitalized. | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) |
Code Block |
---|
| {{ "my great title" | capitalize }} |
|
Code Block |
---|
| {{ dynamicfields.nome | capitalize }} |
|
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)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/error.png) |
|
|
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)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/error.png) |
|
|
date | Converts 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
. | | default | Allows you to specify a fallback in case a value doesn’t exist. default will show its value if the left side is nil , false , or empty. | ![(error)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/error.png) | |
divided_by | Divides a number by the specified The input uses the same format as Ruby’s Time.parse . |
|
|
default | Allows you to specify a fallback in case a value doesn’t exist. default will show its value if the left side is nil , false , or empty. | ![(error)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/error.png) |
|
divided_by | Divides a number by the specified number. | ![(warning)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/warning.png) | Does not work on dynamicfields.
Code Block |
---|
| {{ 16 | divided_by: 4 }}
|
Code Block |
---|
| {{ subTotal| divided_by: 4 }} |
|
downcase | Makes each character in a string lowercase. It does not affect strings that are already all lowercase. | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) |
Code Block |
---|
| {{ "Parker Moore" | downcase }} |
Code Block |
---|
| {{ dynamicfields.nome | downcase}} |
|
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)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/error.png) |
|
escape_once | Escapes a string without changing existing escaped entities. It doesn’t change strings that don’t have anything to escape. | ![(error)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/error.png) |
|
first | Returns the first item of an array. |
| Assuming the userid dynamicfield contains "1,2,3,4,5". Code Block |
---|
| {% assign my_array = dynamicfields.userid | split: "," %}
{{ my_array.first }} |
Code Block |
---|
| {% assign my_array = "apples, oranges, peaches, plums" | split: ", " %}
{{ my_array.first }} |
|
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)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/error.png) |
|
join | Combines the items in an array into a single string using the argument as a separator. | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) | Assuming the userid dynamicfield contains "1,2,3,4,5".
Code Block |
---|
| {% assign my_array = dynamicfields.userid | split: "," %}
{{ my_array | join: " and " }}
|
Code Block |
---|
| 1 and 2 and 3 and 4 and 5 |
Code Block |
---|
| {% assign beatles = "John, Paul, George, Ringo" | split: ", " %}
{{ beatles | join: " and " }} |
Code Block |
---|
| John and Paul and George and Ringo |
|
last | Returns the last item of an array. | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) | Assuming the userid dynamicfield contains "1,2,3,4,5". Code Block |
---|
| {% assign my_array = dynamicfields.userid | split: "," %}
{{ my_array.last}} |
Code Block |
---|
| {% assign my_array = "apples, oranges, peaches, plums" | split: ", " %}
{{ my_array.last }} |
|
lstrip | Removes all whitespaces (tabs, spaces, and newlines) from the beginning of a string. The filter does not affect spaces between words. | ![(error)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/error.png) |
|
map | Creates an array of values by extracting the values of a named property from another object. | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) | Assuming the products contains:
Code Block |
---|
| {
"products": [{
"title": "Product 1",
"price": 100
}, {
"title": "Product 2",
"price": 200
}, {
"title": "Product 3",
"price": 300
}]
} |
Code Block |
---|
| {% assign all_titles = products | map: "title" %}
{% for item in all_titles %}
{{ item }}
{% endfor %} |
Code Block |
---|
| Product 1
Product 2
Product 3 |
|
minus | Subtracts a number from another number. | ![(warning)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/warning.png) | Does not work on dynamicfields. |
16divided_by4
4 |
subTotaldivided_by4100![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png)
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)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/warning.png) | Does not work on dynamicfields. |
"ParkerMoore"|downcase
parker moore |
dynamicfields.nomedowncaseluke |
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 |
newline_to_br | Replaces every newline (\n ) with an HTML line break (<br> ). | ![(error)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/error.png) |
| escape_once | Escapes a string without changing existing escaped entities. It doesn’t change strings that don’t have anything to escape. | ![(error)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/error.png) | |
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)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) | Assuming the TotalIncome dynamic field contains 500. |
% assign my_array =userid split: "," %}
{{ my_array.first 1 |
% assign my_array = "apples, oranges, peaches, plums" | split: ", " %}
{{ my_array.first }}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)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/error.png) | |
join | Combines the items in an array into a single string using the argument as a separator. | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) | Assuming the userid dynamicfield contains "1,2,3,4,5". |
prepend | Adds the specified string to the beginning of another string. | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) |
Code Block |
---|
| {{ "apples, oranges, and bananas" | prepend: "Some fruit: " }} |
Code Block |
---|
| Some fruit: apples, oranges, and bananas |
|
{% assign my_array =userid split,%}
my_array join" and "
1 and 2 and 3 and 4 and 5 |
Code Block |
---|
| {{ "Welcome" | prepend: dynamicfields.Name }} |
|
remove | Removes every occurrence of the specified substring from a string. | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) | |
%assignbeatles="John, Paul, George, Ringo" | split: ", " %}
{{ beatles | join: " and see the train through the rain" | remove: "rain" }} |
|
JohnandPaul and George and Ringolast | Returns the last item of an array. | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) | Assuming the userid dynamicfield contains "1,2,3,4,5".% assign my_array =userid split, %
{{ my_array.last} 5 |
% assign my_array = "apples, oranges, peaches, plums" | split: ", " %}
{{ my_array.last {"Luke Skywalker" | remove: dynamicfields.Name}} |
|
plumslstrip all whitespaces (tabs, spaces, and newlines) from the beginning of a string. The filter does not affect spaces between words.![(error)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/error.png) | TODO: dovrebbe funzionare | map | Creates an array of values by extracting the values of a named property from another object. | | |
minus | Subtracts a number from another number. | ![(warning)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/warning.png) | Does not work on dynamicfields.only the first occurrence of the specified substring from a string. | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) | |
4 "I strained to see the train through the rain" | |
|
minus2 2 |
I sted to see the train through the rain |
|
replace | Replaces every occurrence of an argument in a string with the second argument. | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) | |
SubTotal "Take my protein pills and put my helmet on" | |
|
minus 100900 |
modulo | Returns the remainder of a division operation. | ![(warning)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/warning.png) | Does not work on dynamicfields.
Code Block |
---|
|
{{ 3 | modulo: 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)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) |
Code Block |
---|
| {% assign my_string = "Take my protein pills and put my helmet on" %}
{{ my_string | replace_first: "my", "your" }} |
|
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)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/error.png) |
|
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)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) | Does not work on dynamicfields.
|
SubTotalmodulo:64 |
newline_to_br | Replaces every newline (\n ) with an HTML line break (<br> ). | ![(error)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/error.png) | |
plus | Adds a number to another number. | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) | Assuming the TotalIncome dynamic field contains 500.
|
rstrip | Removes all whitespace (tabs, spaces, and newlines) from the right side of a string. | ![(error)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/error.png) |
|
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)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) | |
dynamicfields.TotalIncome| plus: 2 "Ground control to Major Tom." | size }} |
|
502 |
Code Block |
---|
| {% assign my_array = "apples, oranges, peaches, plums" | split: ", " %}
{{ my_array |
|
5plus: 27prepend | Adds the specified string to the beginning of another string |
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)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) | |
apples, oranges, and bananasprepend"Some fruit: " |
Some fruit: apples, oranges, and bananas |
Assuming title contains "Return to the future" |
dynamicfields.Nameprepend"Hello " Hello Luke |
Code Block |
---|
| {{ dynamicfields. |
|
Nameprependdynamicfields.SurnameOutputLuke Skywalker
Code Block |
---|
|
{{ "Welcome" | prepend: dynamicfields.Name }} |
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)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/warning.png) | Same behavior of the sort_natural filter.
|
{"I strained to see the train through the rain" | remove: "rain" }} Code Block |
---|
|
I sted to see the t through the |
Code Block |
---|
|
{{ dynamicfields.Name| remove: "uk"assign my_array = "zebra, octopus, giraffe, Sally Snake" | split: ", " %}
{{ my_array | sort_natural | join: ", " }} |
|
Le |
Code Block |
---|
|
{{"Luke Skywalker" | remove: dynamicfields.Name}} |
remove_first | Removes only the first occurrence of the specified substring from a stringgiraffe, octopus, Sally Snake, zebra |
|
sort_natural | Sorts items in an array by a property of an item in the array. | ![(error)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/error.png) |
|
split | Divides 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)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) | |
{ "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 %} |
|
Istedtoseethetrainthrough the rainreplace | Replaces every occurrence of an argument in a string with the second argument. | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png)
Assuming the dynamic field albumid contains "1,2,3,4,5" |
{ "Take my protein pills and put my helmet on"% assign ids= dynamicfields.albumid | |
|
replace"my "your}} Code Block |
---|
|
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)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) | |
reverse | Reverses the order of the items in an array. reverse cannot reverse a string. | ![(error)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/error.png) | |
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)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) | |
rstrip | %}
{% for id in ids%}
{{ id }}
{% endfor %} |
|
strip | Removes all whitespace (tabs, spaces, |
and newlines) from the right side of a string.![(error)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/error.png) | TODO: dovrebbe funzionare | 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)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) | |
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)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) | |
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)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/warning.png) | |
sort_natural | Sorts items in an array by a property of an item in the array. | | |
split | Divides 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)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) | |
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)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/error.png) | TODO: dovrebbe funzionare |
strip_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)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/warning.png) | |
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)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) | |
TODO: dovrebbe funzionareand newlines) from both the left and right sides of a string. It does not affect spaces between words. | ![(error)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/error.png) |
|
strip_html | Removes any HTML tags from a string. | ![(tick)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) |
Code Block |
---|
| {{ "Have <em>you</em> read <strong>Ulysses</strong>?" | strip_html }} |
Code Block |
---|
| Have you read Ulysses? |
|
strip_newlines | Removes any newline characters (line breaks) from a string. | ![(error)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/error.png) |
|
times | Multiplies a number by another number. | ![(warning)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/warning.png) | Does not work on dynamicfields.
Code Block |
---|
| {{ 24 | times: 7 }} |
|
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)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) |
Code Block |
---|
| {{ "Ground control to Major Tom." | truncate: 20 }} |
Code Block |
---|
| Ground control to... |
Code Block |
---|
| {{ "Ground control to Major Tom." | truncate: 25, ", and so on" }} |
Code Block |
---|
| 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)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/warning.png) | ![(error)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/error.png) |
|
uniq | Removes any duplicate elements in an array. | ![(error)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/error.png) |
|
|
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)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/check.png) |
Code Block |
---|
| {{ dynamicfields.name | upcase }}
|
|
url_decode | Decodes a string that has been encoded as a URL or by url_encode . | ![(error)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/error.png) |
|
|
url_encode | Converts any URL-unsafe characters in a string into percent-encoded characters. | ![(error)](/wiki/s/417386969/6452/6d51c36b8214055e3f7a2c32741588f0d7c80bed/_/images/icons/emoticons/error.png) |
|