+813-444-3589+44 118 328 3220+49-231-976765-0 | Contact us

Liquid placeholders

In Liquid we differentiate between two kind of Liquid tags: commands and values. A command is enclosed by {% … %} while a value is enclosed by {{ … }}.

The different possible commands will be explained later on, here just an example of how commands generally look like:

{% if collections.size > 5 %}
  <Some (HTML) code>
{% endif %}

Some commands are block oriented, meaning that between the command and the end-command (if and endif) a new block is defined. For these always a matching end command is needed. Other commands (like assign) are self-contented, no ending command is needed.

The Liquid values are replaced by their appropriate value. E.g. {{ collections.size }} in the template would be replaced by 8 (as an example, depending on how many collections there are for the given shop). It is possible to modify the specified value using so called filters. A filter always start behind a value with a | character and modifies the value by the specified filter. Some filter need parameters which are specified behind the filter and a ':'. The result is a new value on which again a filter can be specified. The detailed list of filters will be shown later on. As an example for the syntax of filters:

{{ item.content | strip_html | truncatewords: 40 | highlight: search.terms }}

This will use the content/description (item.content) and remove all HTML code (strip_html filter), the result is truncated after 40 words (truncatewords filter) and finally all words with the given search terms are highlighted (highlight filter).

Please remark that the final result of each value operator should be a base type (int, float or string - see the next chapter for details), other objects and lists will create an error message as replacement for the placeholder (when using the debug environment - in a release environment the output will be empty).

When working with the placeholders, it is important to know of which type each placeholder is, as some operations only work on specific data types. A list of all supported data types follows.


Read more

More about object types

More about variables