Parser: Introduce HTMLConditionalOpenTagNode#1153
Merged
Conversation
commit: |
🌿 Interactive Playground and Documentation PreviewA preview deployment has been built for this pull request. Try out the changes live in the interactive playground: 🌱 Grown from commit ✅ Preview deployment has been cleaned up. |
marcoroth
added a commit
that referenced
this pull request
Feb 13, 2026
This pull request updates the type system to support discriminated unions for AST node fields instead of using the generic `Node` type as the common ancestor. The `config.yml` schema definitions have been updated to specify exact union types for fields like: * `HTMLElementNode.open_tag` (now `HTMLOpenTagNode | HTMLConditionalOpenTagNode`) (see #1153) * `ERBIfNode.subsequent` (now `ERBIfNode | ERBElseNode`) * `HTMLAttributeValueNode.children` (now `LiteralNode | ERBContentNode`) * `HTMLCloseTagNode.children` (now `WhitespaceNode`) The code generation templates have been updated across all language bindings. TypeScript now generates proper union types and the `is*Node` type guard functions have been updated to accept `null | undefined` for easier chaining. Ruby generates union type signatures in RBS files. Rust adds a new `union_types.rs` file with enum types and conversion functions for each union. With these type improvements the linter, formatter, and language server code has been simplified to use `is*Node` type guards instead of manual `.type === "AST_*"` string checks. This removes numerous `as any` and `as *Node` casts that were previously needed, making the code more type-safe and readable.
This was referenced Feb 24, 2026
marcoroth
added a commit
that referenced
this pull request
Feb 24, 2026
…1240) This pull request updates the conditional element analysis passes to no longer produce false `ConditionalElementMultipleTagsError` errors on valid templates containing complete HTML elements inside ERB control flow branches. The following template now parses without any errors: ```html+erb <% if true %> <% if true %> <div> <div></div> <% if true %><% end %> </div> <% else %> <div></div> <% end %> <% end %> ``` Related #1153 Related #1146 Related #1208 Resolves #1239
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.
This pull request adds a new
HTMLConditionalOpenTagNodeAST node type for representing ERB conditionals that only vary the open tag (typically attributes) while sharing the same tag name, body content, and close tag.Previously, this pattern was incorrectly parsed as mismatched tags. Now, Herb detects this pattern and creates a proper
HTMLElementNodewith anHTMLConditionalOpenTagNodeas itsopen_tag, allowing the formatter, linter, and other tools to understand the structure correctly:Follow up on #1146
Resolves #83
Resolves #398
Resolves #490
Resolves #779