Skip to content

Parser: Support kwarg shorthand for Action View Helper attributes#1433

Merged
marcoroth merged 2 commits intomainfrom
parser-kwargs-short
Mar 20, 2026
Merged

Parser: Support kwarg shorthand for Action View Helper attributes#1433
marcoroth merged 2 commits intomainfrom
parser-kwargs-short

Conversation

@marcoroth
Copy link
Owner

@marcoroth marcoroth commented Mar 20, 2026

While working on #1432 I noticed that our keyword argument extraction logic for Action View Tag Helpers doesn't 100% produce the right syntax tree for attributes.

Given the following example:

<%= tag.div(id:) %>

Now with this pull request and action_view_helpers: true it parses as:

@ DocumentNode (location: (1:0)-(1:19))
└── children: (1 item)
    └── @ HTMLElementNode (location: (1:0)-(1:19))
        ├── open_tag: 
        │   └── @ ERBOpenTagNode (location: (1:0)-(1:19))
        │       ├── tag_opening: "<%=" (location: (1:0)-(1:3))
        │       ├── content: " tag.div(id:) " (location: (1:3)-(1:17))
        │       ├── tag_closing: "%>" (location: (1:17)-(1:19))
        │       ├── tag_name: "div" (location: (1:8)-(1:11))
        │       └── children: (1 item)
        │           └── @ HTMLAttributeNode (location: (1:12)-(1:12))
        │               ├── name: 
        │               │   └── @ HTMLAttributeNameNode (location: (1:12)-(1:12))
        │               │       └── children: (1 item)
        │               │           └── @ LiteralNode (location: (1:12)-(1:12))
        │               │               └── content: "id"
        │               │       
        │               ├── equals: ":" (location: (1:12)-(1:12))
        │               └── value: 
        │                   └── @ HTMLAttributeValueNode (location: (1:12)-(1:12))
        │                       ├── open_quote: ∅
        │                       ├── children: (1 item)
        │                       │   └── @ RubyLiteralNode (location: (1:12)-(1:12))
-       │                       │       └── content: "id:"
+       │                       │       └── content: "id"
        │                       │       
        │                       ├── close_quote: ∅
        │                       └── quoted: false
        │                       
        ├── tag_name: "div" (location: (1:8)-(1:11))
        ├── body: []
        ├── close_tag: 
        │   └── @ HTMLVirtualCloseTagNode (location: (1:19)-(1:19))
        │       └── tag_name: "div" (location: (1:8)-(1:11))
        │       
        ├── is_void: false
        └── element_source: "ActionView::Helpers::TagHelper#tag"

@github-actions github-actions bot added the c label Mar 20, 2026
@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 20, 2026

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

commit: 4c5c2e9

@github-actions
Copy link

github-actions bot commented Mar 20, 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 4c5c2e9


✅ Preview deployment has been cleaned up.

@marcoroth marcoroth added this to the v1.0.0 milestone Mar 20, 2026
@marcoroth marcoroth merged commit a25dec0 into main Mar 20, 2026
32 checks passed
@marcoroth marcoroth deleted the parser-kwargs-short branch March 20, 2026 03:05
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