else
An else
can only exists within a condition statement, and is triggered when your preceding condition(s) where not met and you wish to default to something.
liquid
{% else %}
block_to_output
1
2
2
block_to_output
: Rendered expression where no previous conditions were 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
{% if product.track_inventory == true %}
<span>There only 15 items left. Hurry up!</span>
{% else %}
<span>Supply is limited. Hurry up!</span>
{% endif %}
1
2
3
4
5
2
3
4
5
Output
There only 15 items left. Hurry up!