Conditional tags allow you to control the flow of your templates.
Conditional tags let you execute code only if a certain condition is met. This allows for creating dynamic templates that respond to different states and data.
Executes one of many blocks of code, depending on the value of a variable.
Copy
{% case variable %} {% when value1 %} // code to execute if variable equals value1 {% when value2 %} // code to execute if variable equals value2 {% else %} // code to execute if variable doesn't match any values{% endcase %}
{% assign level = "advanced" %}{% case level %} {% when "beginner" %} Start with the basics {% when "intermediate" %} Build on your knowledge {% when "advanced" %} Tackle complex concepts {% else %} Select a level{% endcase %}