ma
marcoroth
GitHub
herb
Workspace
GitHub
CI Pipeline Executions
Current execution
Succeeded
main
Configuration
Self-Healing CI
Project Graph
Resource Usage
Analysis
Conformance
Runs
Current run
Succeeded
Tasks
Resource Usage
Insights
Compare tasks
Analytics
Sign in
Toggle sidebar
Engine: Introduce `SlotSubtree` to render the markup a slot covers (#2283) This pull request introduces `Herb::Engine::SlotSubtree`, which compiles the markup behind one slot, for the two cases a payload of values cannot carry. `SlotIndex#apply` reports a deferred entry when the page is asked for something values cannot express, which is a conditional taking a branch that never rendered, and a collection gaining an item there is no row to copy. Both name a slot, and nothing on the server answered one. ```ruby subtree = Herb::Engine::SlotSubtree.new(source, filename: "app/views/posts/index.html.erb") view.instance_eval(subtree.source_for(0)) #=> "<li>one</li><li>two</li>" ``` `SubtreeCompiler` renders the node at a `node_path` and `SlotVisitor` records the `node_path` of every slot, so a slot index is all that is needed to reach its markup. The two agreeing on what a `node_path` means is what makes this a lookup. #### An attribute is refused A path indexes an element's body and does not descend into its open tag, so an attribute slot's path names the element holding it. Compiling that would hand back `<div class="card">x</div>` where the caller asked for `card`. Those slots are values, and values is how they come back. #### Asking for only what changed `subtree_slots` says which slots a change needs markup for, so a request naming what changed can be answered without asking the page. ```ruby dependencies.subtree_slots("app/views/posts/index.html.erb", ["@admin"]) #=> [{ file: ".../index.html.erb", version: "a1b2c3d4", index: 0, mode: :structural }] ``` Only structural slots appear, because that is the whole of what values cannot say. Changing something a branch merely displays asks for nothing. #### What this does not do It does not make the render cheaper. `SubtreeCompiler` runs the whole template and keeps one node's output, which its own documentation says is the answer that is correct without knowing which expressions the target depends on: > Pruning the work that only fed discarded output is a separate question, and answering it needs to know which expressions the target actually depends on. Running everything is the answer that is correct without that analysis. That analysis now exists, so the question can be asked. It is not asked here, because answering it means changing what the compiler emits and taking on the side effects that come with skipping work.
nx build @herb-tools/tailwind-class-sorter
⌘K
Succeeded
nx build @herb-tools/tailwind-class-sorter
Click to copy
Linux
2 CPU cores
read-write
access token used
d36e19fb
main