adammark/Markup.js

Access property from parent when inside loop

kouts opened this issue · 1 comments

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?

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