feat: add Range to HTMLComment nodes#1229
Merged
Conversation
Collaborator
|
Great, this looks good thanks! |
dgrundel
added a commit
to dgrundel/templ
that referenced
this pull request
Jul 29, 2025
Co-authored-by: Daniel <daniel@grundel.local>
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.
Hi again, this adds a
Rangeto the parser'sHTMLCommentnodes.Note on testing:
I am planning to stick to reusing the existing unit tests and to just update to include ranges. I'm finding that the current set of tests have a good range of inputs. If I spot any missing edge cases, I'll add more tests. Obviously, I'm happy to add any additional tests that you feel are needed as well. Just let me know if you see any gaps.
Use case notes:
As noted previously, my particular use case for these ranges is for linting Templ code. With each of these PRs I'll add a few words on why a range is useful for this particular element (i.e. why would you want to lint this?)
In the case of HTML comments, you may want to create a rule to forbid them entirely, or at least to ensure that they do not contain commented code. In addition to bloating the payload you send to your visitors, HTML comments may also leak unnecessary information. In most cases -- at least in my organization -- Go comments are preferred.