Skip to content

Support filters in conditional tags#195

Merged
edgurgel merged 3 commits intoedgurgel:mainfrom
jareddellitt:support-filters-in-conditions
Apr 25, 2026
Merged

Support filters in conditional tags#195
edgurgel merged 3 commits intoedgurgel:mainfrom
jareddellitt:support-filters-in-conditions

Conversation

@jareddellitt
Copy link
Copy Markdown
Contributor

Fixes #194

Filters in {% if %}, {% elsif %}, and {% unless %} tags stopped working in 1.x. The BinaryCondition and UnaryCondition structs already had filter fields (left_argument_filters, right_argument_filters, argument_filters) but they were never populated during parsing or used during evaluation.

This updates ConditionExpression.parse/1 to use Argument.parse_with_filters/1 instead of Argument.parse/1, and passes the captured filters through to Argument.get/4 during evaluation.

Enables templates like:

{% if items | size > 0 %}...{% endif %}
{% if name | upcase == "JOHN" %}...{% endif %}
{% unless items | size > 0 %}...{% endunless %}

@jareddellitt jareddellitt marked this pull request as ready for review February 17, 2026 22:33
@jareddellitt
Copy link
Copy Markdown
Contributor Author

I pointed our code at the forked branch and wrote some additional tests that passed as expected.

@edgurgel
Copy link
Copy Markdown
Owner

Hey @jareddellitt thanks for the PR!

It turns out that Solid 0.18 implemented something that the original Liquid doesn't support... oops!

I think we can maintain this feature but I would like to have this as an opt-in feature that people have to toggle to enable it given that it diverges from what the original Liquid supports.

Something like Solid.parse(template, filters_in_conditional_tags: true) or any other better name for this new option.

WDYT?

@jareddellitt
Copy link
Copy Markdown
Contributor Author

Hey @jareddellitt thanks for the PR!

It turns out that Solid 0.18 implemented something that the original Liquid doesn't support... oops!

I think we can maintain this feature but I would like to have this as an opt-in feature that people have to toggle to enable it given that it diverges from what the original Liquid supports.

Something like Solid.parse(template, filters_in_conditional_tags: true) or any other better name for this new option.

WDYT?

Yes, that seems reasonable.

@barkerja
Copy link
Copy Markdown
Contributor

Hey @jareddellitt, thanks for this contribution! Do you plan on applying the suggestion @edgurgel made above? I recently got bit by this as part of an upgrade, and I'm happy to contribute if you're not able!

Thanks!

@jareddellitt
Copy link
Copy Markdown
Contributor Author

@barkerja sorry, forgot about this! Just pushed up a commit to make this optional.

Copy link
Copy Markdown
Contributor

@barkerja barkerja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues here. Thanks!

@edgurgel
Copy link
Copy Markdown
Owner

Thanks, team! I will review this in the next couple of days and get a new release cut out. ❤️

Copy link
Copy Markdown
Owner

@edgurgel edgurgel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@edgurgel edgurgel merged commit 7ee8348 into edgurgel:main Apr 25, 2026
3 checks passed
@edgurgel
Copy link
Copy Markdown
Owner

1.3.0 is out! 🎉

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support filters in if, elseif, unless conditions (regression from 0.17)

3 participants