if
Conditionally render HTML blocks using boolean expressions, value comparisons, and empty cell fallbacks in Liquid templates.
Syntax
{% if condition %} ... {% elsif condition %} ... {% else %} ... {% endif %}Example
{% assign status = "active" %}{% if status == "active" %}Service Available{% else %}Service Pending{% endif %}Output
Service AvailableThe if tag executes a block of HTML only when its condition evaluates to true. You can chain conditions using elsif and provide fallback markup with else. Every block must end with endif.
Empty keyword cells become nil in Liquid. Since nil evaluates to false, test for presence using {% if row.attribute %}. For example, provide a default when a feature is absent: {% if row.feature %}{{ row.feature }}{% else %}Standard service included.{% endif %} to prevent thin content warnings.
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
