Skip to content

fix(comment): support nested comment blocks - #1017

Merged
harttle merged 1 commit into
harttle:masterfrom
zzoraemon043:fix/nested-comment
Nov 26, 2026
Merged

harttle merged 1 commit into
harttle:masterfrom
zzoraemon043:fix/nested-comment

Conversation

@zzoraemon043

Copy link
Copy Markdown
Contributor

Part of #1004 (nested comments).

Ruby Liquid counts nested {% comment %} blocks, so the inner {% endcomment %} does not close the outer comment. LiquidJS stopped at the first {% endcomment %} and then failed on the second one:

{% comment %}{% comment %}x{% endcomment %}{% endcomment %}
  • before: tag "endcomment" not found
  • after: empty output

The comment tag now keeps a depth counter. {% raw %} inside a comment is already one token from the tokenizer, so a comment or endcomment inside raw is still ignored. A comment whose nested block is not closed now throws not closed.

Covers the two Golden Liquid cases tags/comment:nested comment blocks and nested comment blocks, with nested tags, plus whitespace control and the {% liquid %} tag. The new tests fail on master (5 of them) and pass with the change; full jest suite passes.

A {% comment %} inside a comment now needs its own {% endcomment %}, like Ruby Liquid, instead of the first {% endcomment %} closing the outer comment.
@harttle
harttle merged commit b62dfb7 into harttle:master Nov 26, 2026
14 checks passed
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.

2 participants