According to the mustache RFC
A {{name}} tag in a basic template will try to find the name key in
the current context. If there is no name key, nothing will be
rendered.
I therefore expected this:
var template = '{{#anArray}}{{aString}}{{/anArray}}';
var json = {
"aString":"ABC",
"anArray": [1,{"aString":"DEF"}]
};
To give me once rendered:
"DEF"
However mustache.js looks for values in the parent’s scope. Which gives me
"ABCDEF"
Do the context actually means including all the parents scopes ?
Short answer: yes.
A bit longer answer.
Context.prototype.lookupdoes a while loop, looking up a token in current context and it’s parent contexts, while there is a parent context.Relevant bit of code: