Articles in this section

key helper

This data variable provides the current index location in an array or the key names in the context. The key is the index value of the array. When iterating through values in an array, the output always starts with 0.

Template

Context

Output

{{#each array}}
{{@key}}
{{/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 2 3
{{#each array}}
{{@key}}
{{/each}}
{
  "title": "My New Post",
  "body": "This is my first post!",
  "array": ["one","two","three","four"],
  "message": "This is the message.",
  "child": {
    "childTitle": "Child Title",
    "childBody": "Child Body"
  }
}
0 1 2 3
{{#each @root.child}}
{{@key}}
{{/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"
  }
}
childTitle
childBody

{{#each @root}}
{{@key}}
{{/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"
  }
}
title body array
message child