php-liquid icon indicating copy to clipboard operation
php-liquid copied to clipboard

Support default allow_false=true

Open torreytsui opened this issue 2 years ago • 2 comments

Hello 👋

Any thought to support the allow_false feature to the default filter?

https://shopify.github.io/liquid/filters/default/#allowing-false

{% assign display_price = false %}
{{ display_price | default: true, allow_false: true }}

Test Case: https://github.com/Shopify/liquid/blob/c99c93255d55129652e262e87c27d359628f71e6/test/integration/standard_filter_test.rb#L782-L792

torreytsui avatar Jan 26 '23 12:01 torreytsui

I'm down to review a PR that add this feature.

sanmai avatar Jan 26 '23 13:01 sanmai

For now, I worked around it with a if-condition.

{% assign display_price = false %}

{%- if display_price == false %}
false
{%- else %}
true
{%- endif %}

torreytsui avatar Feb 24 '23 10:02 torreytsui