I have a use case in which I would like to access parent tags in sections of a list loop in a JS Mustache / Hogan template.
For example, this is my data structure:
var data = { users: [{name: "John", age: 100},{name: "Max", age: 80}], meta: {membership: "full"} };
.. and this is my Mustache / Hogan JS template:
{{
.. which displays as:
<h1>Hello there, John</h1> <h1>Hello there, Max</h1>
This is all good and good, but is it possible for me to access the parent variable meta.membership in {{# users} ... {{/ users}} ? The tags seem to be limited by the local context, so I can not infer the value of the meta.membership tag during iteration over users.
Ideally, I want to know if something like this is possible:
{{
Desired Result:
<h1>Hello there, John</h1> <p>You have a full membership</p> <h1>Hello there, Max</h1> <p>You have a full membership</p>
Thank you in advance
source share