I was able to find an answer to this which was more simple than I thought:
{{cars.length}}
will show the sum of the number of objects in the array.
I was able to find an answer to this which was more simple than I thought:
{{cars.length}}
will show the sum of the number of objects in the array.
I have the following simple handlebarsjs
email HTML template:
<script id="emailTemplate" type="text/x-handlebars-template">
<div>
Hi {{name }} , you have submitted {{ SUM_OF_ARRAY_OBJECTS}} cars. Thanks.
</div>
</script>
With the json
content:
{
"name": "john",
"cars": [
{
"registration": "stubReg1",
"year": "1995"
},
{
"registration": "stubReg2",
"year": "2000"
},
{
"registration": "stubReg3",
"year": "2010"
},
{
"registration": "stubReg4",
"year": "2016"
}
]
}
How can I display the total number of array objects in the SUM_OF_ARRAY_OBJECTS
placeholder using handlebars? i.e. 4 in this example.