Skip to content

Client: Rename a collection's "row" to an "item" and fold content anchor - #2278

Merged
marcoroth merged 4 commits into
slots/dev-toolsfrom
slots/items
Aug 18, 2026
Merged

Client: Rename a collection's "row" to an "item" and fold content anchor#2278
marcoroth merged 4 commits into
slots/dev-toolsfrom
slots/items

Conversation

@marcoroth

@marcoroth marcoroth commented Aug 18, 2026

Copy link
Copy Markdown
Owner

This pull request settles the vocabulary of the slot marker format on one set of words, and reduces the two attributes that anchor a slot to an element down to one.

Nothing outside this stack reads the format yet, which is the only reason this is cheap. Every one of these changes is breaking, and each gets more expensive the longer it waits.

row is table vocabulary, and a collection repeats <li>, cards and <option> as readily as it repeats <tr>. The slot type beside it is already collection, and a collection has items, which is also what Rails calls them when render collection: renders one partial per item.

<!--herb-item:0:42--><li data-herb-slot="1:child">Marco</li><!--/herb-item:0-->
{ 0 => { items: { "42" => { 1 => "Marco" } } } }
slots.itemsFor(file, 0)
slots.slotInItem(file, 0, "42", 2)
slots.updateItem(collection, "42", html)

Also, an element's content slot had an attribute of its own while every other slot on that element was in data-herb-slot, and the index called what the first one produced a content anchor, so the format and the index disagreed about its name.

The anchor kind is a property of the slot's type and does not need an attribute to carry it. child means the value goes inside the element, and every other type on that attribute means the element itself:

-<li id="1" data-herb-slot="1:attribute:id" data-herb-child="2">Marco</li>
+<li id="1" data-herb-slot="1:attribute:id 2:child">Marco</li>

The list is space-separated now, which is what HTML uses for token lists, and it means a slot can be found with a selector instead of by parsing the attribute:

document.querySelectorAll('[data-herb-slot~="2:child"]')

~= matches one token of a whitespace-separated list, so the comma form could not be queried this way. A content-only element grows three characters, an element carrying both roles shrinks by a whole attribute.

Some values of SlotOperation named what kind of thing changed and two named what happened to one item, and rewriting an item's markup fell through to markup with a key set:

-{ operation: "markup", key: "42" }
+{ operation: "item-updated", key: "42" }

markup keeps its meaning for a whole slot rewritten at once, which is the case that carries no key. Nothing read the operation except the Dev Tools flash, which looks it up in a colour map, so this costs one entry there. No test covered that path before, and one does now.

Slots are experimental and the marker format is not stable yet.

@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 dev-tools @herb-tools/dev-tools visual debugging for HTML+ERB templates labels Aug 18, 2026
@marcoroth marcoroth added reactivity Reactive ERB templates: diff and re-render only what changed and removed 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 dev-tools @herb-tools/dev-tools visual debugging for HTML+ERB templates labels Aug 18, 2026
@nx-cloud

nx-cloud Bot commented Aug 18, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 2200b03

Command Status Duration Result
nx run-many -t test --all --parallel --exclude=... ✅ Succeeded 4m 8s View ↗
nx run-many -t build --all --exclude=herb-langu... ✅ Succeeded 43s 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 12:37:46 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 2200b03


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

commit: 2200b03

The operation an event carries named what kind of thing changed, except for
items, where it named what happened to one. Rewriting an item's markup fell
through to `markup` with a key set, so a listener had to read "markup plus a
key" as "an item was replaced", while the item appearing or leaving said so
outright.

`item-updated` says it. `markup` keeps its meaning for a whole slot rewritten at
once, which is the case that carries no key.
@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 dev-tools @herb-tools/dev-tools visual debugging for HTML+ERB templates labels Aug 18, 2026
@marcoroth marcoroth changed the title Client: Call a collection's repeated unit an item Client: Rename a collection's "row" to an "item" and fold content anchor Aug 18, 2026
@marcoroth
marcoroth merged commit d7c8a74 into main Aug 18, 2026
33 of 34 checks passed
@marcoroth
marcoroth deleted the slots/items 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. dev-tools @herb-tools/dev-tools visual debugging for HTML+ERB templates 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