Tags
Tags are markup for programming logic within Live Editor themes.
Tag markup does not output anything but allows you to code logic into your templates. Tags are surrounded by matched pairs of curly brackets and percent signs:
Tags can be broken down into 4 categories:
Base tags
There are a few tags available for meeting basic programming needs like commenting, escaping, and including templates.
Control flow tags
Control Flow tags determine which block of code should be executed based on different conditions.
-
if
,elsif
, andelse
- Only execute code if a certain condition is met.
-
unless
-
The inverse of
if
: only execute code if a certain condition is not met. -
case
,when
, andelse
-
Creates a switch statement looking for the first
when
match for the value passed tocase
.
Iteration tags
Iteration tags allow you to loop through a collection of values and execute code for each item.
-
for
,break
, andcontinue
- Allows you to iterate over an array and execute code for each item in the array.
-
cycle
- Accepts a list of strings as parameters and cycles through each one and outputs it.
Layout tags
Layout tags provide hooks and settings for layout functionality like editable regions and navigation menus.
-
navigation
- Allows you to indicate where in a layout to place the markup for a navigation menu.
-
region
- Defines where to place editable regions within a layout.
Variable tags
Use these tags to create new variables in your Liquid templates.
-
assign
- Creates a new variable.
-
capture
- Captures the string inside of the opening and closing tags and assigns it to a variable.
-
increment
-
Creates a new number variable, increases its value by
1
every time it is called, and outputs it. -
decrement
-
Creates a new number variable, decreases its value by
1
every time it is called, and outputs it.
Next steps
Continue your deep dive into Liquid with the Object Reference.