Expressions and scope
Expressions are useful only when their scope is explicit. LZR tracks <set> bindings, component inputs, <foreach> item/index frames, protocol reads, and jq projections so the Inspector and agents can explain where a rendered value came from.
1 <set key="releasedCount"
2 value="{{ items | jq:'[.[] | select(.href)] | length' }}" />
3
4 <h2>{{ releasedCount }} -- {{ testNumber }} already available</h2>
5 <p>prefix {{ testNumber }} suffix</p>
6
7 <foreach items="{{ items }}" key="item">
8 {{ index + 1 }}. {{ item.title }}
9 </foreach> {{ item.title }}Foreach frame current loop
itemobjectCurrent item from the foreach
indexnumberZero-based loop index
Template bindings <set> declarations
releasedCountnumberjq projection over items
testNumbernumberLiteral scalar set at the top of the page
From data reads
data://items.jsonarraySource array bound to items
{{ item.title }}{{ item.title }}Expression itemForeach item binding itemsIterated collection data://items.jsonOrigin data read Scope records
What the scope map should explain
| Record | Example role | Inspector behavior |
|---|---|---|
| Binding definition | A set-like value or component prop. | Ctrl-click variable jumps to the owner expression. |
| Binding use | A text or attribute emission. | Hover highlights sibling uses in the same lexical scope. |
| Foreach item | Current item value. | Hover highlights the corresponding foreach frame, not unrelated loops. |
| Foreach index | Current zero-based index. | Highlight stays scoped to the active loop. |
| Protocol read | Concrete data or source resource. | Ctrl-click navigates to the Data tab or source owner. |
hypermake lzr scope-map src/expressions/mixed.html hypermake affected-by src/expressions/mixed.html hypermake explain rendered/public/expressions/mixed.html