Skip to content

Engine: Report template values as payload that names where they belong - #2273

Merged
marcoroth merged 1 commit into
slots/clientfrom
slots/values
Aug 18, 2026
Merged

Engine: Report template values as payload that names where they belong#2273
marcoroth merged 1 commit into
slots/clientfrom
slots/values

Conversation

@marcoroth

@marcoroth marcoroth commented Aug 18, 2026

Copy link
Copy Markdown
Owner

This pull request turns what DynamicsCompiler produces from a bare Hash of indices into a payload that says which template, version and rendering the values came from, so a client can join them to the markers on the page.

{ template: "app/views/posts/index.html.erb", version: "aaaaaaaa", occurrence: 0, slots: { 0 => "Marco" } }

An index is a position in one template's numbering and means something else in the next, so a bare Hash of them cannot be joined to anything. Carrying the identifier and version SlotVisitor gave the markers lets a client tell the two were compiled together, and that a version no longer matching means the indices are not to be trusted.

That shape is also what a partial needs. <%= render "posts/card" %> evaluates to the partial's own values, and coercing them to a string flattened a whole payload into the markup it was meant to replace. A render keeps its value as it is, so a partial nests as a payload of its own, as deeply as the template does.

A template on the page more than once has one region per rendering, and counting them down the document holds only while render order and document order agree, which content_for and provide break by design. The region marker carries the number now, counted as the page renders, so the client reads the server's own answer instead of inferring one. The counter hangs off the view, which in Rails is the request, so every response starts at zero and a partial shares the count with the template that rendered it.

The round trip is what proves the two halves agree. It renders a template twice, hands the second rendering's values to the first rendering's markers, and asserts the page is byte for byte what the server would have sent. Nothing else says the numbering, the row keys, the attribute names and the collapsed conditional are all right at once, and each of them is wrong in a way that leaves the page looking plausible. Swapping two indices in the fixture fails the round trip, which is the check that the check is worth having.

@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
@marcoroth marcoroth added the reactivity Reactive ERB templates: diff and re-render only what changed label Aug 18, 2026
@nx-cloud

nx-cloud Bot commented Aug 18, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit cd58803

Command Status Duration Result
nx run-many -t test --all --parallel --exclude=... ✅ Succeeded 3m 59s 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:19 UTC

@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 cd58803


✅ 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@2273
npx https://pkg.pr.new/@herb-tools/language-server@2273
npx https://pkg.pr.new/@herb-tools/linter@2273

commit: cd58803

@marcoroth marcoroth added the client-runtime Browser runtime for the Herb slots. label Aug 18, 2026
@marcoroth
marcoroth merged commit 8db87a2 into main Aug 18, 2026
60 of 67 checks passed
@marcoroth
marcoroth deleted the slots/values 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