Skip to content

Instantly share code, notes, and snippets.

@nanusdad
Created August 6, 2013 05:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nanusdad/6162141 to your computer and use it in GitHub Desktop.
Save nanusdad/6162141 to your computer and use it in GitHub Desktop.
Handlebars - each with @key and @Index
When looping through items in each, you can optionally reference the current loop index via {{@index}}
{{#each array}}
{{@index}}: {{this}}
{{/each}}
For object iteration, use {{@key}} instead:
{{#each object}}
{{@key}}: {{this}}
{{/each}}
From: http://handlebarsjs.com/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment