Expressions provide a simple method to describe dynamic text content.
Our expressions are based on the open-source Liquid template language with some custom filter additions.
Expressions can be categorized into objects, filters and tags.
Objects describe where to insert dynamic content in your expression and are denoted by double curly braces: {{
and }}
.
The following objects are available to your expression:
NOW | Current time (in timezone of Source) |
THIS | Reference to Node of current expression |
SOURCE | Reference to Source of current expression |
LOCATION | Reference to Location of current expression |
WORKSPACE | Reference to Workspace of current expression |
In the following example, the expression refers to an object called WORKSPACE
, which has an attribute called name
, and that object attribute contains the text Workspace 01
.
Input
{{ WORKSPACE.name }}
Output
Workspace 01
Note
A full list of available object attributes are described here.
Filters change the output of an object. They are used within an output and are separated by a |
.
Input
{{ "/my/fancy/url" | append: ".html" }}
Output
/my/fancy/url.html
Multiple filters can be used on one output. They are applied from left to right.
Input
{{ "adam!" | capitalize | prepend: "Hello " }}
Output
Hello Adam!
Note
A full list of available filters are described here
Tags create the logic and control flow for templates. They are denoted by curly braces and percent signs: {%
and %}
.
The markup used in tags does not produce any visible text. This means that you can assign variables and create conditions and loops without showing any of the logic in the content.
Input
{% if user %}
Hello {{ user.name }}!
{% endif %}
Output
Hello Adam!
Note
A full list of available tags are described here
Liquid operators are very simple and different. There’re 2 types of operators supported:
==
, !=
, >
, <
, >=
, <=
or
, and
, contains
Thus numerical operators are not supported and you cannot even plus two
numbers like this {{a + b}}
, instead we need a filter {{ a | plus: b}}
.
According to shopify documentation everything other than false
and
nil
/null
is truthy. Our implementation is slightly different:
value | truthy | falsy |
---|---|---|
true |
✔️ | |
false |
✔️ | |
nil /null |
✔️ | |
undefined |
✔️ | |
string |
✔️ | |
empty string |
✔️ | |
0 |
✔️ | |
integer |
✔️ | |
float |
✔️ | |
array |
✔️ | |
empty array |
✔️ |