Contents of this document were more or less copied from here http://handlebarsjs.com/reference.html. The resulting document is tailored to our implmentation.
@root returns the initial context. You can use this, when you're nested inside block helpers, to gain access to objects in the original context.
Context
{
"value": "test",
"someObject": {
"id": 1,
"name": "object"
}
}Usage
Result
<div>
<span>test</span>
<ul>
<li>object</li>
<li>test</li>
</ul>
</div>@first will return true if the current iteration of a loop is the first.
Context
{
"array": [
{
"id": 1
},
{
"id": 2
},
{
"id": 3
}
]
}Usage
Result
<ul>
<li>
<span>1: </span>
<span>First</span>
</li>
<li>
<span>2: </span>
<span>Not First</span>
</li>
<li>
<span>3: </span>
<span>Not First</span>
</li>
</ul>@last will return true if the current iteration of a loop is the first.
Context
{
"array": [
{
"id": 1
},
{
"id": 2
},
{
"id": 3
}
]
}Usage
Result
<ul>
<li>
<span>1: </span>
<span>Not Last</span>
</li>
<li>
<span>2: </span>
<span>Not Last</span>
</li>
<li>
<span>3: </span>
<span>Last</span>
</li>
</ul>@index will return the current index of the array when iterating over a loop.
Context
{
"array": [
{
"id": 1
},
{
"id": 2
},
{
"id": 3
}
]
}Usage
Result
<ul>
<li>
<span>1: </span>
<span>0</span>
</li>
<li>
<span>2: </span>
<span>1</span>
</li>
<li>
<span>3: </span>
<span>2</span>
</li>
</ul>@key returns the property name of the current context. You'd typically use this when looping over an object.
Context
{
"someObject": {
"id": 1,
"name": "object"
}
}Usage
Result
<ul>
<li>id</li>
<li>name</li>
</ul>this returns the current context. You can use it to explore the current path or to return the current value of the current context.
Context
{
"value": "test",
"someObject": {
"id": 1,
"name": "object"
},
"array": [
1,
2,
3
]
}-
Usage
Result
<div> <span>test</span> <ul> <li>object</li> <li>test</li> </ul> </div>
-
Usage
Result
<ul> <li>1</li> <li>2</li> <li>3</li> </ul>
-
Usage
Result
<ul> <li>1</li> <li>object</li> </ul>