Skip to content

Client: Properly address a slot inside markup a helper like content_for captured - #2275

Merged
marcoroth merged 1 commit into
slots/applyfrom
slots/displaced
Aug 18, 2026
Merged

Client: Properly address a slot inside markup a helper like content_for captured#2275
marcoroth merged 1 commit into
slots/applyfrom
slots/displaced

Conversation

@marcoroth

Copy link
Copy Markdown
Owner

This pull request makes a slot addressable when content_for, provide or capture moved it away from the template that numbered it.

Those helpers run during one rendering and hand their markup to whoever wants it, which is usually somewhere else on the page. The markers go with it, so a slot ended up outside the markers of the template that numbered it, and the client, attributing slots by where they sit, gave it to whatever enclosed it instead. The value for it was in the payload the whole time and nothing could find the place to put it.

Captured markup carries its own region marker now, naming the same template, version and rendering as the template around it, so it says where it belongs wherever it is emitted. It reads the number instead of counting again, which is what makes it the same rendering and not another one.

On the client, a region is no longer a stretch of the page between two markers. A rendering is identified by its template, version and number, so two markers naming the same one are the same one. A region holds a list of ranges, is kept while any of them is still on the page, and contains a node that any of them contains. Nothing about addressing changes: a slot inside a content_for is slots.slot(file, index) like any other, however far from the rest of its template it ended up.

Matching by name only covers the helpers that can be named. A helper that captures its block privately is indistinguishable from one that renders it in place, and no amount of reading the ERB will tell them apart. Matching one that renders in place costs a marker pair saying something true, so this errs towards matching.

On RubyEvents' announcements page the head now carries the action template's marker fifty thousand characters from the rest of it, and the slot inside is addressable as that template's and not as the layout's.

@marcoroth marcoroth added the reactivity Reactive ERB templates: diff and re-render only what changed label Aug 18, 2026
@github-actions github-actions Bot added ruby Ruby source for the gem and its libraries typescript TypeScript source across the javascript/ packages rbs RBS type signatures in sig/ engine Herb engine and Rails template compilation rubygem The herb RubyGem and its packaging labels Aug 18, 2026
@nx-cloud

nx-cloud Bot commented Aug 18, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit a2f4b20

Command Status Duration Result
nx run-many -t test --all --parallel --exclude=... ✅ Succeeded 3m 41s View ↗
nx run-many -t build --all --exclude=herb-langu... ✅ Succeeded 16s View ↗
nx build @herb-tools/tailwind-class-sorter ✅ Succeeded 1s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-08-18 03:13:39 UTC

@marcoroth marcoroth added the client-runtime Browser runtime for the Herb slots. label Aug 18, 2026
@github-actions

github-actions Bot commented Aug 18, 2026

Copy link
Copy Markdown

🌿 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 a2f4b20


✅ Preview deployment has been cleaned up.

@pkg-pr-new

pkg-pr-new Bot commented Aug 18, 2026

Copy link
Copy Markdown
npx https://pkg.pr.new/@herb-tools/formatter@2275
npx https://pkg.pr.new/@herb-tools/language-server@2275
npx https://pkg.pr.new/@herb-tools/linter@2275

commit: a2f4b20

@marcoroth
marcoroth merged commit 03840a3 into main Aug 18, 2026
42 of 43 checks passed
@marcoroth
marcoroth deleted the slots/displaced branch August 18, 2026 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

client-runtime Browser runtime for the Herb slots. engine Herb engine and Rails template compilation rbs RBS type signatures in sig/ reactivity Reactive ERB templates: diff and re-render only what changed ruby Ruby source for the gem and its libraries rubygem The herb RubyGem and its packaging typescript TypeScript source across the javascript/ packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant