Skip to content

WIP3 - #2021

Draft
charlespwd wants to merge 16 commits into
cp-expression-refactorfrom
cp-boolean-expressions
Draft

WIP3#2021
charlespwd wants to merge 16 commits into
cp-expression-refactorfrom
cp-boolean-expressions

Conversation

@charlespwd

@charlespwd charlespwd commented Dec 3, 2025 •

Copy link
Copy Markdown
Contributor

Features

  • Add support for boolean expressions everywhere
    • As variable output {{ a or b }}
    • As filter argument {{ collection | where: 'prop', a or b }}
    • As tag argument {% render 'snip', enabled: a or b %}
    • As conditional tag argument {% if cond %} (extending previous behaviour)
  • Add support for subexpression prioritization and associativity
    • In ascending order of priority:
      • Logical: and, or (right to left)
      • Equality: ==, !=, <> (left to right)
      • Comparison: >, >=, <, <=, contains (left to right)
      • Groupings: ( expr )
    • For example, this is now supported
      • {{ a > b == c < d or e == f }} which is equivalent to
      • {{ ((a > b) == (c < d)) or (e == f) }}
  • Add support for parenthesized expressions
    • e.g. (a or b) == c

Notable passing test

  def test_assign_boolean_expression_assignment
    assert_template_result(
      'it rendered',
      <<~LIQUID,
        {%- assign should_render = a == 0 or (b == 1 and c == 2) -%}
        {%- if should_render -%}
          it rendered
        {%- endif -%}
      LIQUID
      { 'b' => 1, 'c' => 2 },
    )
  end

@charlespwd
charlespwd force-pushed the cp-boolean-expressions branch 5 times, most recently from ccb81f8 to f62b920 Compare December 5, 2025 14:59
@charlespwd
charlespwd force-pushed the cp-boolean-expressions branch from f62b920 to a33443c Compare December 5, 2025 16:40
@charlespwd
charlespwd force-pushed the cp-boolean-expressions branch from a33443c to 4fcd443 Compare January 27, 2026 14:59
@charlespwd
charlespwd force-pushed the cp-boolean-expressions branch from 4fcd443 to 3b13ee0 Compare January 27, 2026 15:08
charlespwd and others added 16 commits October 26, 2026 20:59
Instead of having Condition parse the left op right, make
BinaryExpression do it. Make sure all the tests pass as they
used to in the process.
It was incompatible with the lexer anyway. Not used internally either.
- Remove comparison expression logic
- Remove Condition#child_relation
- Remove Condition#and
- Remove Condition#or
- Simplify Condition#evaluate

This logic was moved to the Parser & BinaryExpression
- Use right-recursive descent for proper RTL precedence
- Add bin/liquid-spec-all-adapters for CI workflow
- Update CI to use dedicated script

Fixes 128 precedence test failures from original implementation.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@charlespwd
charlespwd force-pushed the cp-boolean-expressions branch from 26cb294 to ecf53f7 Compare October 27, 2026 01:12
@charlespwd charlespwd mentioned this pull request Oct 27, 2026
@charlespwd
charlespwd added this pull request to stack #2135 October 27, 2026 18:07

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant