Add tests for finding and changing Glimmer template comment content#10
Merged
NullVoxPopuli merged 3 commits intoApr 20, 2026
Conversation
Covers all three comment syntaxes supported in Glimmer templates:
- HTML comments: <!-- --> (GlimmerCommentStatement)
- Short mustache comments: {{! }} (GlimmerMustacheCommentStatement)
- Long mustache comments: {{!-- --}} (GlimmerMustacheCommentStatement)
Tests verify finding by type, filtering by value or source-slice,
replacing content while preserving surrounding markup, removing
comments entirely, and handling all three types in mixed templates
including class-based components and nested block expressions.
Depends on ember-estree keeping comment nodes in GlimmerTemplate.body
with semantic types rather than converting them to "Block".
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Picks up GlimmerCommentStatement and GlimmerMustacheCommentStatement
nodes in GlimmerTemplate.body with longForm support for {{!-- --}}.
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
| const root = j(source, { filePath: "test.gjs" }); | ||
|
|
||
| root.find("GlimmerCommentStatement").replaceWith("<!-- updated html -->"); | ||
| root.find("GlimmerMustacheCommentStatement").replaceWith("{{! updated mustache }}"); |
Owner
There was a problem hiding this comment.
we should also have a test for targeting short and long mustaches individually
When both {{! }} and {{!-- --}} appear in the same template, source-slice
filtering distinguishes them so each form can be replaced independently.
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
8783c99 to
24520a1
Compare
Merged
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
Adds
tests/glimmer-comments.test.tswith 23 tests covering find + replace for all three Glimmer comment syntaxes.Depends on NullVoxPopuli/ember-estree#31, which keeps comment nodes in
GlimmerTemplate.bodywith semantic types.What's tested
HTML comments (
<!-- -->)GlimmerCommentStatement)Short mustache comments (
{{! }})GlimmerMustacheCommentStatement)Long mustache comments (
{{!-- --}})GlimmerMustacheCommentStatement)Mixed scenarios
.gjscomponents{{#if}}block expressionsTest plan
pnpm test— all tests pass🤖 Generated with Claude Code