I have some test data that looks like this:
{
"firstName":"Ben",
"products": [{
"name": "first product",
"position": 0
}, {
"name": "second product",
"position": 1
}, {
"name": "third product",
"position": 2
}]
}
In my template, I have something like this:
<p>Hi {{firstName}}</p>
Which works fine. Now I want to loop through my products
So I tried this:
{{#each products}}
{{#if this.position == 0}}
<h1>{{this.name}}</h1>
{{else}}
<h2>{{this.name}}</h2>
{{/if}}
{{/each}}
But it doesn't work. I also can't find any documentation about doing if statements like that. The closest I found was:
https://sendgrid.com/docs/ui/sending-email/using-handlebars/
And it talks about "Basic If, Else, Else If" which suggests there is a more advanced version, but I can't find the documentation for it....
Does anyone know what I am doing wrong?
PS: my examples are simplified just for this post.