Files
liquid/filters/default.md
2016-03-18 16:48:27 -04:00

741 B

title
title
default

Allows you to specify a fallback in case a value doesn't exist. default will show its value if the left side is nil, false, or empty.

In this example, product_price is not defined, so the default value is used.

{% raw %}
{{ product_price | default: 2.99 }}
{% endraw %}
2.99

In this example, product_price is defined, so the default value is not used.

{% raw %}
{% assign product_price = 4.99 %}
{{ product_price | default: 2.99 }}
{% endraw %}
4.99

In this example, product_price is empty, so the default value is used.

{% raw %}
{% assign product_price = "" %}
{{ product_price | default: 2.99 }}
{% endraw %}
2.99