Articles in this section

index helper

This data variable gives you the current index in an array iteration or in a JSON iteration in the context of #each.

Template

Context

Output

{{#each @root.child}}
{{@index}}
{{/each}}
{
  "title": "My New Post",
  "body": "This is my first post!",
  "array": [1,2,3,4],
  "message": "This is the message.",
  "child": {
    "childTitle": "Child Title",
    "childBody": "Child Body"
  }
}
0 1
{{#each @root.people}}
{{@index}}
{{/each}}
{
  "people": [
    "Bertram Gilfoyle",
    "Erlich Bachman",
    "Jin Yang"
  ]
}
0 1 2