when
Declare one or more matching values within a case block to trigger specific template markup.
Syntax
{% case variable %} {% when value1, value2 %} ... {% endcase %}Example
{% assign fruit = "apple" %}{% case fruit %}{% when "banana" %}Yellow Fruit{% when "apple" %}Red Fruit{% endcase %}Output
Red FruitThe when tag defines one or more target values within a surrounding case statement. When the inspected variable matches any listed value, its associated block renders. Multiple values can be separated by commas.
In programmatic landing page templates, when tags group similar attribute values into unified presentation blocks. For example: {% case row.coverage %}{% when 'downtown', 'metro' %}<span class="badge">Express 30-Min</span>{% when 'rural' %}<span>Scheduled</span>{% endcase %}. This pairs dynamic badges with rows.
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
