Video outline

As you learned in the section Get started, a liquid template is created by writing a sequence of lines in the liquid editor. Silverfin will then render these lines into a what the template looks like in input view. The syntax is the "set of language rules" which is interpreted by the liquid editor.

Different programming languages use different kinds of syntax. What languages usually share, is that syntax should always be exactly right to work out well. Small errors in syntax can make the code not work or make big differences in outcome. Different programming languages use different kinds of syntax.

Types of liquid syntax

The input you provide in the liquid editor can be categorised into four types:

Plain text

The liquid editor accept text input as any other text editor. What you will write in the editor, will be shown in the template.

Print syntax

Using print syntax means telling Silverfin not to print what you write directly (as with plain text), but that it should check whether the text you write has a certain meaning, and then print that meaning.

Print syntax is always written between double brackets: {{ your_print_syntax }}. These brackets mean that liquid will try to ‘translate’ what is within them, such as a variable or a calculation, into something which can be printed.

Logic syntax

A certain set of predetermined commands (‘tags’) allow for certain functionality, such as control flow & logic, loops or creating variables (see Introduction to variables ).

Logic syntax is always written between brackets with percentage symbols: {% your_logic_syntax %}. These brackets mean that certain words within them, such as assign, capture, if, for etc. have a specific predetermined meaning in liquid, triggering a certain functionality. The other classes in the liquid academy will explain these functionalities in depth.

Style syntax

The plain text at above, but also printed code output from can be styled in different ways. Most of the syntax under this section originates from the markup language markdown.

Examples of different types of syntax

The following liquid code example shows each of the syntax types described above:

{% assign my_age = 31 %}

my age:

{{ my_age }}

my age large and in bold:

{::font size="l"}**{{ my_age }}**{:/font}

In this example, note the following:

  • The texts ‘my age:’ and ‘my age in large and in bold:’ are examples of plain text
  • The variable my_age is printed two times, which is print syntax (can be recognised by the {{ ... }} delimiters)
  • The assign statement above is logic syntax (can be recognised by the {% .. %} delimiters)
  • The bottom row shows examples of style syntax: the {::font size="l"} tag together with the markdown for bold text (**) ensures that the second time my_age is printed, it is larger and in bold (see below)
  • Note the difference between {% .. %} and {{ ... }} !

Silverfin processes this syntax into the following template content: