-
Notifications
You must be signed in to change notification settings - Fork 75
Closed
Description
Forked from this comment: #10 (comment)
Data Sample:
name: 'Hello World'
users:
- name: 'Bill'
pets:
- name: 'Yoda'
- type: 'Cat'
- name: 'Steve'
pets:
- name: 'Wayne'
- type: 'Llama'
@janl I, like you, am still on the fence about the ../ notation.
Generally, there are a few ways to conceive of a solution:
- Explicit address (ala handlebars.js), which provides access to literally everything on the stack, but necessarily exposes the implementation of the stack immediately to users. (e.g. are inverted section values put on the stack?)
- Dot notation with a root anchor, sort of the inverse of handlebars' addressing, would permit you to do fully manual stack traversals (e.g.
{{ @.name }}would always resolve to'Hello World', regardless of stack depth). The downsides to this approach are again exposing the underlying implementation, and eschewing the power of the context stack entirely. - Reverse traversals could again solve this particular problem, but fails to solve the more general problem of providing access to any/all masked keys.
- Skips would allow you to inform the stack traversal to bypass one or more results, which nicely solves the problem of accessing any masked value, but introduces a new syntactic construct that has the potential for abuse. The most attractive feature of this solution is the fact that stil relies on the underlying stack traversal code; this is strictly advice passed to that routine. (e.g.
{{ name' }}: not the topmost occurrence of name, but the second;{{ name'' }}: the third occurrence of name)
Of these options, I'm most inclined to support the idea of "skips" at this point.
Metadata
Metadata
Assignees
Labels
No labels