Skip to content

Parser: Fix Action View Helpers with positional arguments and block#1406

Merged
marcoroth merged 3 commits intomainfrom
parser-tag-with-argument-and-block
Mar 17, 2026
Merged

Parser: Fix Action View Helpers with positional arguments and block#1406
marcoroth merged 3 commits intomainfrom
parser-tag-with-argument-and-block

Conversation

@marcoroth
Copy link
Owner

@marcoroth marcoroth commented Mar 17, 2026

This pull request fixes how the parser handles Action View tag helpers when both positional arguments and an inline block are present.

Previously, content_tag and tag.* would use the positional content argument even when a block was given. Rails always prefers the block content, so now the parser matches that behavior:

<%= content_tag(:div, "ignored") { "Block wins" } %>
<!-- Rails renders: <div>Block wins</div> -->

This also fixes attribute extraction for link_to when the second argument is an explicit hash literal or a variable:

<%= link_to("/about", { class: "btn" }) { "About" } %>
<!-- Now correctly extracts: href="/about", class="btn", body="About" -->
<%= link_to("/about", html_opts) { "About" } %>
<!--  Variable options are now represented as RubyHTMLAttributesSplatNode -->

Follow up on #1404

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 17, 2026

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

commit: 3280d03

@github-actions
Copy link

github-actions bot commented Mar 17, 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 3280d03


✅ Preview deployment has been cleaned up.

@marcoroth marcoroth merged commit 5ac1b52 into main Mar 17, 2026
32 checks passed
@marcoroth marcoroth deleted the parser-tag-with-argument-and-block branch March 17, 2026 10:47
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