feat: add Range to raw elements (RawElement, ScriptElement)#1231
Merged
feat: add Range to raw elements (RawElement, ScriptElement)#1231
Conversation
Owner
|
Looks good! re: tests for this section, the parser tests check that the elements can be parsed into the object model well, but there's also formatting tests and generation tests that cover the same area from different angles. You might be interested in #1230 which uses prettier to format In that PR, I've also refactored the |
dgrundel
added a commit
to dgrundel/templ
that referenced
this pull request
Aug 16, 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, back again! This time adding Range to the elements included in the
rawElementsparser:RawElementandScriptElement.Testing: Here again I just updated the existing tests. Testing is a little slim for these elements, let me know if you'd like to see additional cases added.
Use case notes: In my organization we generally ban script and style tags directly in markup, preferring CSS and JS served from CDNs. (Or, better yet, no additional CSS at all except for those provided by Tailwind.) In cases where they are allowed, you want to be able to extract the contents of these tags and run them through separate, language-specific tools (e.g. stylelint, eslint). Lastly, there's a common pattern where server-side state is emitted into the page by inserting a script tag (with
typelikeapplication/json) containing only a JSON payload. For these we'd want to ensure a consistenttypeattribute, perhaps require anid, and ensure that the contents of the tag is only a single go expression.