case
Match a single variable against multiple possible values using when statements for clean multi-branch logic.
Syntax
{% case variable %} {% when value %} ... {% else %} ... {% endcase %}Example
{% assign tier = "gold" %}{% case tier %}{% when "gold" %}Gold Benefits{% when "silver" %}Silver Benefits{% else %}Basic Info{% endcase %}Output
Gold BenefitsThe case tag initiates a multi-way switch statement that inspects a single variable and matches it against discrete values declared with when tags. It provides a readable alternative to lengthy if-elsif chains.
On keyword combination landing pages, case statements organize layouts around product types or service models. For example: {% case row.service_type %}{% when 'emergency' %}24/7 on-call dispatch.{% when 'scheduled' %}Flexible booking windows.{% else %}Standard service.{% endcase %}. This structures copy cleanly.
Filters
- abs
- append
- at_least
- at_most
- capitalize
- ceil
- compact
- concat
- date
- default
- divided_by
- downcase
- escape
- escape_once
- first
- floor
- join
- last
- lstrip
- map
- minus
- modulo
- newline_to_br
- plus
- prepend
- remove
- remove_first
- replace
- replace_first
- reverse
- round
- rstrip
- size
- slice
- sort
- sort_natural
- split
- strip
- strip_html
- strip_newlines
- times
- truncate
- truncatewords
- uniq
- upcase
- url_decode
- url_encode
- where
- raw
- slugify
- number_format
