Skip to content

Instantly share code, notes, and snippets.

@robmint
Created January 6, 2016 01:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robmint/d577c73f716cbf722611 to your computer and use it in GitHub Desktop.
Save robmint/d577c73f716cbf722611 to your computer and use it in GitHub Desktop.
Iterating over a list of lists in a Handlebars template
<!--- json input data:
index: [
[
{divider: true, text: "A", url: ""},
{text: "ACCTG 371", url: "", count:23},
{text: "ACCTG 371", url: "", count:23},
{text: "ACCTG 371", url: "", count:23},
{text: "ACCTG 371", url: "", count:23},
{text: "ACCTG 371", url: "", count:23}
],
[
{divider: true, text: "F", url: ""},
{text: "ACCTG 371", url: "", count:23},
{text: "ACCTG 371", url: "", count:23},
{text: "ACCTG 371", url: "", count:23},
{text: "ACCTG 371", url: "", count:23}
],
[
{divider: true, text: "J", url: ""},
{text: "ACCTG 371", url: "", count:23},
{text: "ACCTG 371", url: "", count:23},
{text: "ACCTG 371", url: "", count:23},
{text: "ACCTG 371", url: "", count:23}
]
]
-->
{{#each index}}
<ul class="plain-list col-3">
{{#each this}}
{{#if divider}}
<li><a class="header">{{text}}</a></li>
{{else}}
<li><a href="{{url}}">{{text}}<span class="badge">{{count}}</span></a></li>
{{/if}}
{{/each}}
</ul>
{{/each}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment