Skip to content

Question regarding multi-level each #582

Closed
@Jezternz

Description

@Jezternz

Hi, I am looking for a templating engine and handlebars looks pretty great!
However I have some rather advanced requirements and I am not sure if handlebars is capable, or if it is,
what the syntax should look like. I have tried below to describe my problem.
eg given the following json structures:

var x = [{"XX":1},{"XX":3}];
var z = [
  "a":{
    1:{"Q":"A"},
    2:{"Q":"B"},
    3:{"Q":"C"},
    4:{"Q":"D"}
  }
];

I need to be able to template something like this:

<ul>
{{#each x}}
  {{#each z.a.(this.XX).Q}}
    <li>Item - {{this}}</li>
  {{/each}}
{{/each}}
</ul>

// Where 'this' refers to the element from the most outer loop
and output something like this:

<ul>
  <li>Item A</li>
  <li>Item C</lI>
</ul>

Any ideas on whether this is possible and what the template syntax should look like would be great! (Or any plans for future implementation).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions