mirror of
https://github.com/kemko/liquid.git
synced 2026-01-04 17:25:41 +03:00
1019 B
1019 B
title, description
| title | description |
|---|---|
| default | Liquid filter that specifies a fallback in case a value doesn't exist. |
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.
Input
```liquid {% raw %} {{ product_price | default: 2.99 }} {% endraw %} ```Output
```text 2.99 ```In this example, product_price is defined, so the default value is not used.
Input
```liquid {% raw %} {% assign product_price = 4.99 %} {{ product_price | default: 2.99 }} {% endraw %} ```Output
```text 4.99 ```In this example, product_price is empty, so the default value is used.
Input
```liquid {% raw %} {% assign product_price = "" %} {{ product_price | default: 2.99 }} {% endraw %} ```Output
```text 2.99 ```