Skip to content

Parser: Detect turbo_frame_tag helper#1354

Merged
marcoroth merged 2 commits intomainfrom
turbo-tag-helper
Mar 11, 2026
Merged

Parser: Detect turbo_frame_tag helper#1354
marcoroth merged 2 commits intomainfrom
turbo-tag-helper

Conversation

@marcoroth
Copy link
Owner

@marcoroth marcoroth commented Mar 11, 2026

This pull request allows the parser to be able to detect and transform the turbo_frame_tag helper using the action_view_helpers parser option.

For example:

<%= turbo_frame_tag "tray", data: { controller: "frame" } do %>
  Content
<% end %>

Gets parsed as:

@ DocumentNode (location: (1:0)-(3:9))
└── children: (1 item)
    └── @ HTMLElementNode (location: (1:0)-(3:9))
        ├── open_tag: 
           └── @ ERBOpenTagNode (location: (1:0)-(1:63))
               ├── tag_opening: "<%=" (location: (1:0)-(1:3))├── content: " turbo_frame_tag "tray", data: { controller: "frame" } do " (location: (1:3)-(1:61))
               ├── tag_closing: "%>" (location: (1:61)-(1:63))
               ├── tag_name: "turbo-frame" (location: (1:4)-(1:19))
               └── children: (2 items)
                   ├── @ HTMLAttributeNode (location: (1:20)-(1:26))
                      ├── name: 
                         └── @ HTMLAttributeNameNode (location: (1:20)-(1:26))
                             └── children: (1 item)
                                 └── @ LiteralNode (location: (1:20)-(1:26))
                                     └── content: "id"
                             
                      ├── equals: "=" (location: (1:20)-(1:26))
                      └── value: 
                          └── @ HTMLAttributeValueNode (location: (1:20)-(1:26))
                              ├── open_quote: """ (location: (1:20)-(1:26))
                              ├── children: (1 item)
                                 └── @ LiteralNode (location: (1:20)-(1:26))
                                     └── content: "tray"
                                 
                              ├── close_quote: """ (location: (1:26)-(1:26))
                              └── quoted: true
                              
                   └── @ HTMLAttributeNode (location: (1:36)-(1:48))
                       ├── name: 
                          └── @ HTMLAttributeNameNode (location: (1:36)-(1:48))
                              └── children: (1 item)
                                  └── @ LiteralNode (location: (1:36)-(1:48))
                                      └── content: "data-controller"
                                      
                       ├── equals: "=" (location: (1:36)-(1:48))
                       └── value: 
                           └── @ HTMLAttributeValueNode (location: (1:36)-(1:48))
                               ├── open_quote: """ (location: (1:36)-(1:48))
                               ├── children: (1 item)
                                  └── @ LiteralNode (location: (1:36)-(1:48))
                                      └── content: "frame"
                                      
                               ├── close_quote: """ (location: (1:48)-(1:48))
                               └── quoted: true
                   
        ├── tag_name: "turbo-frame" (location: (1:4)-(1:19))
        ├── body: (1 item)
           └── @ HTMLTextNode (location: (1:63)-(3:0))
               └── content: "\n  Content\n"
               
        ├── close_tag: 
           └── @ ERBEndNode (location: (3:0)-(3:9))
               ├── tag_opening: "<%" (location: (3:0)-(3:2))
               ├── content: " end " (location: (3:2)-(3:7))
               └── tag_closing: "%>" (location: (3:7)-(3:9))
               
        ├── is_void: false
        └── element_source: "Turbo::FramesHelper#turbo_frame_tag"

This pull request also updates the rewriters to be able to rewrite from/to the turbo_frame_tag syntax. The above example can be transformed to this and back:

<turbo-frame id="tray" data-controller="frame">
  Content
</turbo-frame>

Follow up on #1122

@github-actions github-actions bot added the c label Mar 11, 2026
Signed-off-by: Marco Roth <marco.roth@intergga.ch>
@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 11, 2026

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

commit: 44b1777

@github-actions
Copy link

github-actions bot commented Mar 11, 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 44b1777


✅ Preview deployment has been cleaned up.

@marcoroth marcoroth merged commit 3e0d5be into main Mar 11, 2026
32 checks passed
@marcoroth marcoroth deleted the turbo-tag-helper branch March 11, 2026 10:24
@marcoroth marcoroth modified the milestone: v1.0.0 Mar 11, 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