#1 2016-02-23 16:28:30

martin.suer
Member
Registered: 2013-12-15
Posts: 76

Mustache question - Accessing higher level context

Hi,

if I have a nested data structure (context) that's passed to a template, can I access variables of an outer context from within a nested context?

sth. like this:

{{#ParentList}}
  {{#Children}}
     {{Name}} is a child of {{#../Father}}
  {{/Children}}
{{/ParentList}}

I understand that within the {{#Children}} tag, the context is switched to the actual element of the Children list. So if I want to access sth. that is up a level in the context hierarchy, is that possible somehow or do I have to create my data structures so that the Father value is an element of the Child to get what I want?

If it's not possible, wouldn't that be a useful extension to the mustache implementation of mORMot?

Thanks
Martin

Offline

#2 2016-02-23 17:21:57

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,225
Website

Re: Mustache question - Accessing higher level context

By design, ParentList members are visible within Children loop.
You just need to take care that the member names do not overlap.

Offline

#3 2016-02-23 17:46:55

martin.suer
Member
Registered: 2013-12-15
Posts: 76

Re: Mustache question - Accessing higher level context

Great, thank you

Offline

Board footer

Powered by FluxBB