Control flow tags
Control flow tags create conditions that decide whether blocks of Liquid code get executed.
Executes a block of code only if a certain condition is met (that is, if the result is
if, but executes a block of code only if a certain condition is not met (that is, if the result is
The above example is the same as:
else / elsif
Adds more conditions to an
case / when
Creates a switch statement to execute a particular block of code when a variable has a specified value.
case initializes the switch statement, and
when statements define the various conditions.
You can optionally add an
else statement at the end of the case to provide code to execute if none of the conditions are met.
Multiple conditions (and / or)
You can use the
or operators to include more than one condition in a control flow tag.
or can be chained together to create complex conditionals.
If you use multiple
or operators, note that
and operators will be evaluated first, then
or operators. You cannot use parentheses to simulate an order of operations and control the order of operator evaluation. Parentheses are invalid characters within Liquid tags and prevent your tags from working.
and operator lets you add additional conditions to a tag. A condition with an
and will only be true if both the left and the right side of the condition are true.
or operator lets you add additional conditions to a tag. A condition with an
or will be true if either the left or the right side of the condition is true.