Flow Tags

Flow Tags

{% assign %}

Stores a value to a variable on the root scope.

{% case %}

Switch-like control flow that compares a value against one or more "when" options and optionally an "else" fallback.

{% capture %}

Captures rendered output as a string into a variable.

{% comment %}

All content between {% comment %} and {% endcomment %} will be ignored. It will not be evaluated or output to the template.

The comment method is primarily used for one of two purposes:

  1. For a developer to leave notes behind so that when they or another developer looks at the code later they understand what it is doing.
  2. To temporarily "remove" a block of code from a template so that it is no longer evaluated but is easy to add back later. This is particularly helpful when troubleshooting a template error.

{% cycle %}

Cycles through a list of strings, returning the next value on each call.

Cycle is typically called inside a for loop.

If you use multiple non-named cycles in your templates, you may end up with unexpected results. To prevent this, we recommend that you always name your cycle groups.

{% decrement %}

Decrements a variable by one and then outputs it to the template.

If the variable does not exist yet, it will be created with an initial value of 0 (-1 after decrementing). If the vartype (var, set, or assign) is not set, this method uses a default vartype of "set" (ie: the current variable will be updated, and if the variable does not exist yet it will be created at the root scope).

{% for %}

Iterates through every item in a list. Executes and outputs a block of code to the template for each item in the list.

{% if %}

Conditional branching to only execute and output a block of code if a certain condition is met. May specify multiple blocks with separate conditions using "elsif"/"elseif" and "else" clauses if desired.

Alternatively, if you only want to execute a block of code if a certain condition is NOT met, use the unless tag instead.

{% ifchanged %}

Executes a block of code, but only outputs it to the template if it results in a different string than the previous time that it was called with the same name.

All calls to ifchanged with no name act as one group. That is, they do not consider the results of calls to ifchanged that have a name specified.

{% include %}

Processes and outputs a partial template, javascript, or stylesheet.

If the partial template is a compiled template, then any custom fields from the partial template will be available in the parent template as well.

The path is significant when including objects. Every template, javascript, and stylesheet has a path, even if that is the root path (/). The location of the path to be included will always be based off of the path of the current object. So including 'header' from a template at the path '/pages' will attempt to process '/pages/header' while the same include from a template at the root path - which would attempt to process '/header'.

You always have the option of using an "absolute path" when including templates by beginning your included template name with '/'. Eg: {% include '/header' %} or {% include '/partials/header' %}. Absolute paths ignore the path of the current template when determining what partial to include.

You can also navigate up the directory structure using '../'. So including '../partials/header' from a template at the path '/agency/pages' will attempt to process '/agency/partials/header'.

{% increment %}

Increments a variable by one and then outputs it to the template.

If the variable does not exist yet, it will be created with an initial value of 0 (1 after incrementing). If the vartype (var, set, or assign) is not set, this method uses a default vartype of "set" (ie: the current variable will be updated, and if the variable does not exist yet it will be created at the root scope).

{% literal %}

Treats enclosed content as plain text without Liquid parsing, which means that the any liquid markup before the matching {% endliteral %} will NOT be evaluated but will be output directly to the template instead.

{% map %}

Creates a new list of strings from the output when a block of liquid markup is executed for each item in a list or collection.

This method behaves exactly the same as the for method, except that instead of outputting the results directly to the template, it saves them in a list instead. It may be helpful to think of the map method as the capture method for lists. You can even assign varaibles by reference (eg: {% map &newcollection for item in oldcollection %}).

Note that you can also use the forloop properties and tags inside a map block (see the for tag documentation for details).

{% raw %}

Treats enclosed content as plain text without Liquid parsing. Alternative version of the {% literal %} method.

{% set %}

Replaces a value on the nearest scope where it has already been defined. If it has not been defined yet, it is stored on the root scope.

{% unless %}

Inverse conditional. Only executes and outputs a block of code if a certain condition is NOT met. May specify additional "elsif"/"elseif" and "else" clauses if desired, which will be treated the same as for the {% if %} method.

{% var %}

Stores a value to a variable on the current scope.