mirror of
https://github.com/kemko/liquid.git
synced 2026-01-01 15:55:40 +03:00
default now has an allow_false parameter
This commit is contained in:
@@ -50,3 +50,21 @@ In this example, `product_price` is empty, so the default value is used.
|
||||
{% assign product_price = "" %}
|
||||
{{ product_price | default: 2.99 }}
|
||||
```
|
||||
|
||||
### Allowing `false` {%- include version-badge.html version="5.0.0" %}
|
||||
|
||||
To allow variables to return `false` instead of the default value, you can use the `allow_false` parameter.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{% raw %}
|
||||
{% assign display_price = false %}
|
||||
{{ display_price | default: true, allow_false: true }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
|
||||
false
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user