Access property from parent when inside loop
kouts opened this issue · 1 comments
kouts commented
Hi! Is it possible to access a property of the parent object when we loop?
For example:
var context = {
name: "John Doe",
brothers: ["Jack", "Joe", "Jim"]
};
var template = "<ul>{{brothers}}<li>{{.}}</li>{{/brothers}}</ul>";
How do I access "name" (John Doe) inside the "{{brothers}}" loop?
adammark commented
Hi, thanks for the question. Sorry to say it's not possible. You should simply modify the data structure before handing it off to the template engine.
Adam