Skip to content

Parser: Support tag.attributes Action View helper#1461

Merged
marcoroth merged 1 commit intomainfrom
tag-attributes
Mar 22, 2026
Merged

Parser: Support tag.attributes Action View helper#1461
marcoroth merged 1 commit intomainfrom
tag-attributes

Conversation

@marcoroth
Copy link
Owner

@marcoroth marcoroth commented Mar 22, 2026

This pull request updates the parser to detect and transform the tag.attributes Action View helper.

With this pull request, the following example:

<input <%= tag.attributes(type: :text, aria: { label: "Search" }) %>>

Now gets parsed as this using action_view_helpers: true:

@ DocumentNode (location: (1:0)-(1:6))
└── children: (1 item)
    └── @ HTMLElementNode (location: (1:0)-(1:69))
        ├── open_tag:
           └── @ HTMLOpenTagNode (location: (1:0)-(1:69))
               ├── tag_opening: "<" (location: (1:0)-(1:1))├── tag_name: "input" (location: (1:1)-(1:6))
               ├── tag_closing: ">" (location: (1:68)-(1:69))├── children: (2 items)
                  ├── @ HTMLAttributeNode (location: (1:26)-(1:37))
                     ├── name:
                        └── @ HTMLAttributeNameNode (location: (1:26)-(1:30))
                            └── children: (1 item)
                                └── @ LiteralNode (location: (1:26)-(1:30))
                                    └── content: "type"
                     
                     ├── equals: ": " (location: (1:30)-(1:32))
                     └── value:
                         └── @ HTMLAttributeValueNode (location: (1:33)-(1:37))
                             ├── open_quote: 
                             ├── children: (1 item)
                                └── @ LiteralNode (location: (1:33)-(1:37))
                                    └── content: "text"
                             
                             ├── close_quote: 
                             └── quoted: false
                  
                  └── @ HTMLAttributeNode (location: (1:47)-(1:62))
                      ├── name:
                         └── @ HTMLAttributeNameNode (location: (1:47)-(1:52))
                             └── children: (1 item)
                                 └── @ LiteralNode (location: (1:47)-(1:52))
                                     └── content: "aria-label"
                      
                      ├── equals: ": " (location: (1:52)-(1:54))
                      └── value:
                          └── @ HTMLAttributeValueNode (location: (1:54)-(1:62))
                              ├── open_quote: """ (location: (1:54)-(1:55))
                              ├── children: (1 item)
                                 └── @ LiteralNode (location: (1:55)-(1:61))
                                     └── content: "Search"
                              
                              ├── close_quote: """ (location: (1:61)-(1:62))
                              └── quoted: true
               └── is_void: false
        
        ├── tag_name: "input" (location: (1:1)-(1:6))
        ├── body: []
        ├── close_tag: 
        ├── is_void: true
        └── element_source: "HTML"

This pull request also updates the rewriter to rewrite from/to:

<input type="text" aria-label="Search">

Enables #1458
Enables #1459

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 22, 2026

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

commit: cd97f5b

@github-actions
Copy link

github-actions bot commented Mar 22, 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 cd97f5b


✅ Preview deployment has been cleaned up.

@marcoroth marcoroth merged commit ee6b125 into main Mar 22, 2026
32 checks passed
@marcoroth marcoroth deleted the tag-attributes branch March 22, 2026 16:26
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