-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for Boolean Expressions in Liquid #1922
base: main
Are you sure you want to change the base?
Conversation
5bba11e
to
a2de2dc
Compare
ooo, is a goal here (explicit or implicit) to deepen the functionality of as in, {% if false and (false or true) %} {%# not supported in main %}
{% if false and false or true %} {%# does not pass in main %}
{% if false || true %} {%# not supported in main %} |
Hey @isaacbowen, sort of! The current focus is to enable more concise boolean statements in output markup. So previously all falsey values would render as nothing. We'd like to support syntax where if |
This looks like a simplified version of the Ternary operator feature request |
yes, yes, yes! and thumbsup for @madsenmm this could be the next step for this. |
Added tests for existing usage cases to avoid breaking important logic when introducing changes in subsequent commits.
* Update test suite to validate parity * Remove parentheses handling * Split boolean into comparison and logical expressions
…llo' }}`) * Evaluate expressions as truthy/falsy to unlock scenarios, such as `<div class="{{ disabled and "modal--disabled" }}">` * Add additional scenarios to the expression test suite * Simplify `LogicalExpression`
756936a
to
08d36b0
Compare
… main
Overview
This PR introduces a syntax improvement to Liquid templates:
Boolean Expression Support: Enhanced boolean handling with proper operator precedence
This change makes templates more readable and concise by allowing developers to write expressions in a more natural way.
Changes
Boolean Expression Enhancements
and
,or
)false and false or true
evaluates totrue
)Before:
After:
Benefits
Testing
Added a new test suite:
boolean_unit_test.rb
: Tests boolean operators, precedence, and assignmentAll tests should pass with the implementation.