Skip to content

Parser: Transform Action View tag helpers inside control flow blocks#1447

Merged
marcoroth merged 1 commit intomainfrom
actionview-tag-helpers-nested
Mar 21, 2026
Merged

Parser: Transform Action View tag helpers inside control flow blocks#1447
marcoroth merged 1 commit intomainfrom
actionview-tag-helpers-nested

Conversation

@marcoroth
Copy link
Owner

@marcoroth marcoroth commented Mar 21, 2026

This pull request fixes a bug in the action_view_helpers parser analysis where tag helpers inside control flow blocks were not being transformed into HTMLElementNode AST representations. They remained as ERBContentNode, making them invisible to consumers relying on the transformed AST.

For example, the following template with action_view_helpers: true:

<% if condition? %>
  <%= tag.img src: "/image.png", alt: "Photo" %>
<% end %>

Previously produced:

  @ ERBIfNode (location: (1:0)-(3:9))
  ├── statements: (1 item)
     └── @ ERBContentNode (location: (2:2)-(2:48))
         ├── tag_opening: "<%=" (location: (2:2)-(2:5))├── content: " tag.img src: \"/image.png\", alt: \"Photo\" " (location: (2:5)-(2:46))
         └── tag_closing: "%>" (location: (2:46)-(2:48))

Now correctly produces:

  @ ERBIfNode (location: (1:0)-(3:9))
  ├── statements: (1 item)
     └── @ HTMLElementNode (location: (2:2)-(2:48))
         ├── open_tag:
            └── @ ERBOpenTagNode (location: (2:2)-(2:48))
                ├── tag_opening: "<%=" (location: (2:2)-(2:5))
                ├── content: " tag.img src: \"/image.png\", alt: \"Photo\" " (location: (2:5)-(2:46))
                ├── tag_closing: "%>" (location: (2:46)-(2:48))
                ├── tag_name: "img" (location: (2:10)-(2:13))
                └── children: (2 items)
                    ├── @ HTMLAttributeNode (name: "src", value: "/image.png")
                    └── @ HTMLAttributeNode (name: "alt", value: "Photo")
         ├── tag_name: "img" (location: (2:10)-(2:13))
         ├── body: []
         ├── close_tag: ├── is_void: true
         └── element_source: "ActionView::Helpers::TagHelper#tag"

@github-actions github-actions bot added the c label Mar 21, 2026
@marcoroth marcoroth changed the title Parser: Handle nested Action View Tag Helper transformation Parser: Transform Action View tag helpers inside control flow blocks Mar 21, 2026
@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 21, 2026

npx https://pkg.pr.new/@herb-tools/formatter@1447
npx https://pkg.pr.new/@herb-tools/language-server@1447
npx https://pkg.pr.new/@herb-tools/linter@1447

commit: c0a7eb9

@github-actions
Copy link

github-actions bot commented Mar 21, 2026

🌿 Interactive Playground and Documentation Preview

A preview deployment has been built for this pull request. Try out the changes live in the interactive playground:


🌱 Grown from commit c0a7eb9


✅ Preview deployment has been cleaned up.

@marcoroth marcoroth merged commit 875047f into main Mar 21, 2026
39 checks passed
@marcoroth marcoroth deleted the actionview-tag-helpers-nested branch March 21, 2026 22:59
@marcoroth marcoroth added this to the v1.0.0 milestone Mar 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant