0

In JavaScript, we can use strict equality (===, !==, etc.) to determine if something is truly false instead of just falsy. I have several nullable booleans in a model that is being passed into a liquid template, and the only mechanism I can come up with is to create a temporary variable that converts the boolean to a string by appending an empty string:

{% assign test = false %}
{% assign test = test | append: "" %}

{% case test %}
  {% when "true" %}
     TRUE
  {% when "false" %}
     FALSE
  {% else %}
     NULL
{% endcase %}

I know liquid doesn't have a complete standard, but this seems to be a problem across all implementations of liquid that I've seen. Is there another way to not have null/nil match the false case without converting it to a string?

user15716642
  • 171
  • 1
  • 12

0 Answers0