This data variable returns true for the first element of an array or an object. When iterating through values in an array, the output always starts with 0.
|
Template |
Context |
Output |
|---|---|---|
{{#each @root.child}}
{{#if @first}}
{{@key}}
{{/if}}
{{/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 |
{{#each array}}
{{#if @first}}
{{@key}}
{{/if}}
{{/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 |
{{#each array}}
{{#if @first}}
{{@key}}
{{/if}}
{{/each}} |
{
"title": "My New Post",
"body": "This is my first post!",
"array": ["apple","orange","pear","banana"],
"message": "This is the message.",
"child": {
"childTitle": "Child Title",
"childBody": "Child Body"
}
} |
0 |