Implement ifchanged Liquid tag - #910
Merged
Merged
Conversation
- Add IfChangedStatement AST node that renders content only when it changes - Register ifchanged/endifchanged block tag in FluidParser - Add visitor methods to AstVisitor and AstRewriter - Enable golden liquid tests for ifchanged tag (5 tests) - Add 9 unit tests in IfChangedStatementTests.cs
Collaborator
|
Is this an offical tag by Shopify? |
Collaborator
|
Are there any missing tags or filters, I need to put my hands dirty again in Fluid :) It has been awhile |
Owner
Author
|
AFAIK everything is implemented, that's why I added Golden Test Suite There are a few skipped tests but mostly because implementing these things could be complex or too expensive for such niche feature. You can always check in the open issues though is there is something intereseting. |
sebastienros
added a commit
that referenced
this pull request
Aug 20, 2026
- Add IfChangedStatement AST node that renders content only when it changes - Register ifchanged/endifchanged block tag in FluidParser - Add visitor methods to AstVisitor and AstRewriter - Enable golden liquid tests for ifchanged tag (5 tests) - Add 9 unit tests in IfChangedStatementTests.cs Co-authored-by: GitHub Copilot CLI <copilot@github.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: ee9c8775-0354-41dd-8226-89a69c60241c
This was referenced Aug 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the
{% ifchanged %}Liquid tag, which outputs content only when it has changed from the previous invocation.Changes
Fluid/Ast/IfChangedStatement.cs- New AST node that:context.AmbientValuesifchangedoutputFluid/FluidParser.cs- Registers theifchanged/endifchangedblock tagFluid/Ast/AstVisitor.cs&AstRewriter.cs- Added visitor methodsFluid.Tests/GoldendLiquidTests.cs- Enabled golden liquid tests (removed skip entry)Fluid.Tests/IfChangedStatementTests.cs- 9 new unit testsBehavior
All
{% ifchanged %}blocks share a single "previous value" in the render context. This matches Shopify Liquid's behavior:{% assign foo = 'hello' %} {% ifchanged %}{{ foo }}{% endifchanged %} {# outputs 'hello' #} {% ifchanged %}{{ foo }}{% endifchanged %} {# no output (unchanged) #} {% assign foo = 'goodbye' %} {% ifchanged %}{{ foo }}{% endifchanged %} {# outputs 'goodbye' #}Common use case - grouping in loops:
{% for item in list | sort %} {% ifchanged %}{{ item }}{% endifchanged %} {% endfor %}Tests
ifchanged tagpass