Add support for # style comments in {% liquid %} blocks
#835
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.
Fixes the issue where lines starting with
#inside{% liquid %}blocks were not treated as comments, causing the parser to skip subsequent statements.Problem
Previously, when using
#comments inside{% liquid %}blocks, the parser would stop processing statements after encountering the comment line:{% liquid assign name = 'John' # very important information assign name = 'Jenna' echo name %}Expected output:
JennaActual output: `` (empty)
The
assign name = 'Jenna'andecho namestatements were being skipped.Solution
Modified the
LiquidTagparser to recognize#as a valid tag identifier in addition to regular identifiers. This allows the parser to properly handle#comments within liquid blocks by leveraging the existing inline comment infrastructure.The key change is in
FluidParser.cs, where the liquid tag parser now uses:This allows
#to be recognized and processed by theInlineCommentTaghandler, which correctly consumes the rest of the line as a comment (since inside liquid blocks, newlines act as tag terminators).Testing
Added comprehensive test coverage:
#comment functionality#with no content)All existing tests (1206) continue to pass, confirming backward compatibility.
Examples
Now works as expected:
{% liquid # required args: assign product = 'MyProduct' # optional args: assign should_show_border = true assign should_show_cursor = true echo product %}Output:
MyProduct✅Regular inline comments outside liquid blocks continue to work:
{% # this is an inline comment %} Hello WorldOutput:
Hello World✅Original prompt
Fixes #834
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.