unless
The opposite of if
, we output the encapsulated block only if the evaluated condition is falsy.
liquid
{% unless condition %}
block_to_output
{% endunless %}
1
2
3
2
3
condition
: Falsy condition to evaluate.block_to_output
: Rendered expression in case the condition is met.
Example
Data
json
{
"product": {
"track_inventory": true
}
}
1
2
3
4
5
2
3
4
5
Note: Data is only refereed as a reference for this example and is in no means reflecting real world data.
liquid
{% unless product.track_inventory == false %}
<span>Supply is limited. Hurry up!</span>
{% endunless %}
1
2
3
2
3
Output
Supply is limited. Hurry up!