Flow Tags

Flow Tags

{% assign %}

Stores a value to a variable on the root scope.

{% assign variable = value %}

{% assign
variable
 
The name of the variable to store the value in, or a reference variable that evaluates to the variable name
=
value
 
The value to store. May use liquid filters.
%}

{% case %}

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

{% case variable %}

{% case
variable_name
 
The name of the variable containing the value to compare against "when" options
%}

{% when options %}

{% when
options
 
One or more values. May use the variable arguments syntax. Values to compare against the case variable to determine if this block should be executed or skipped
%}

Defines the start of the block that will be executed and output to the template if the case variable matches one of the options. Must include at least one option, but may include multiple options separated either by commas or the word "or".

{% else %}

{% else %}

Defines the fallback code that will be executed and output to the template if none of the "when" blocks match the case varaible.

{% endcase %}

{% capture %}

Captures rendered output as a string into a variable.

{% capture [var, set, or assign]? variable %}

{% capture
var, set, or assign
 
Optional. Specify either "var", "set" or "assign" to change which scope this capture is stored on. "var" is the default behavior.
variable
 
The name of the variable to store the output in, or a reference variable that evaluates to the variable name
%}

{% endcapture %}

{% comment %}

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

{% comment [name] %}

{% comment
variable_name
 
Use the name to allow nested comments to also be ignored. If included, the comment will not be closed until an endcomment with the matching name is found.
%}

{% endcomment [name] %}

{% endcomment
name
 
Must exactly match the name from the {% comment %} method. If the {% comment %} method does not include a name then the {% endcomment %} method must also not include a name.
%}

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.

{% cycle [name:]? options %}

{% cycle
name:
 
A name for the cylcle to create an independent cycle group. Must be followed by a colon or else it may be confused with the options. If multiple cycles have the same name, they will share an index (so the second cycle will pick up where the first cycle left off). If the cycle does not have a name, one will automatically be created for it based on the options provided
options
 
One or more values. May use the variable arguments syntax. The list of strings to cycle through
%}

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.

{% decrement [var, set, or assign]? variable %}

{% decrement
var, set, or assign
 
Optional. Specify either "var", "set" or "assign" to change which scope this decrement is stored on. "var" is the default behavior.
variable
%}

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.

{% for item in collection reversed? [limit:num]? [offset:value]? %}

{% for
variable_name
 
The name for the variable to assign each item in the collection to
in
collection
 
One or more values. May use the variable arguments syntax. The list of items to iterate
reversed
 
If true, the items will be iterated in reverse order. Note that this takes effect after the offset and limit are applied
limit
offset
 
The number of items to skip at the beginning of the list. Alternatively, use the keyword "continue" to resume iteration of the list from the last time the same item and collection names were used in a for loop
%}

{% else %}

{% else %}

If there are no items to iterate, the "else" block will be executed and output instead. This may be for several reasons, such as if the collection is not a list or is empty, or if the offset is greater than the size of the list.

{% continue %}

{% continue %}

Skips to the next iteration of the current loop.

{% break %}

{% break %}

Exits the current loop immediately.

{% endfor %}

{% 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.

{% if condition %}

{% if
condition
 
Single or compound condition using 'and'/'or'
%}

{% elsif condition %}

{% elsif
condition
 
Single or compound condition using 'and'/'or'
%}

Secondary condition to evaluate. If none of the previous blocks were executed and the current condition is met, the following block of code will be executed and output to the template.

{% elseif condition %}

{% elseif
condition
 
Single or compound condition using 'and'/'or'
%}

Alternate name for the {% elsif %} method, with the same functionality.

{% else %}

{% else %}

Fallback block of code to execute and output if none of the previous blocks were executed.

{% endif %}

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.

{% ifchanged name %}

{% ifchanged
variable_name
 
Optional, but recommended. A semi-unique name which, when specified, allows the template to use the multiple groups of ifchanged methods simultaneously without replacing the results of the previous call for other groups. May use a reference variable to specify a dynamic name
%}

{% endifchanged %}

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.

{% include [template|javascript|stylesheet]? variable =? attributes? %}

{% include
type
 
Explicit type selector: template, javascript, or stylesheet. If not specified, the object to be included will be the same as the type of the current ojbect (in a template this will default to template, etc...).
variable
 
May be the template, javascript, or stylesheet object to include, the unique identifier for the object to include, or the relative or absolte path to the template, javascript, or stylesheet
=
attributes
 
Key:value pairs with unique keys. May use the variable arguments syntax. Variables to set on the created scope before the included object is processed
%}

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.

{% increment [var, set, or assign]? variable %}

{% increment
var, set, or assign
 
Optional. Specify either "var", "set" or "assign" to change which scope this increment is stored on. "var" is the default behavior.
variable
%}

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.

{% literal %}

{% endliteral %}

{% 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.

{% map [var, set, or assign] variable for item in collection reversed? [limit:num]? [offset:value]? %}

{% map
var, set, or assign
 
Optional. Specify either "var", "set" or "assign" to change which scope this map is stored on. "var" is the default behavior.
variable
for
variable_name
 
The name for the variable to assign each item in the collection to
in
collection
 
One or more values. May use the variable arguments syntax. The list of items to iterate
reversed
 
Causes the collection to be iterated in reverse order. Note that this takes effect after the offset and limit are applied
limit
offset
 
The number of items to skip at the beginning of the list. Alternatively, use the keyword "continue" to resume iteration of the list from the last time the same item and collection names were used in a map loop
%}

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.

{% raw %}

{% endraw %}

{% 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.

{% set variable = expression %}

{% set
variable
 
The name of the variable to store the value in, or a reference variable that evaluates to the variable name
=
value
 
The value to store May use liquid filters.
%}

{% 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.

{% unless condition %}

{% unless
condition
 
Single or compound condition using 'and'/'or'
%}

{% elsif condition %}

{% elsif
condition
 
Single or compound condition using 'and'/'or'
%}

Secondary condition to evaluate. If none of the previous blocks were executed and the current condition is met, the following block of code will be executed and output to the template.

{% elseif condition %}

{% elseif
condition
 
Single or compound condition using 'and'/'or'
%}

Alternate name for the {% elsif %} method, with the same functionality.

{% else %}

{% else %}

Fallback block of code to execute and output if none of the previous blocks were executed.

{% endunless %}

{% var %}

Stores a value to a variable on the current scope.

{% var variable = expression %}

{% var
variable
 
The name of the variable to store the value in, or a reference variable that evaluates to the variable name
=
value
 
The value to store May use liquid filters.
%}