I'm iterating over an array object utilizing express-handlebars
and only every second dom element which is created should have a specific attribute.
Something like this:
<div class=""></div>
<div></div>
<div class=""></div>
<div></div>
I noticed that there is a @size
value which contains the index of the iteration.
My code so far is looking like this:
{{#each todoGroups}}
{{#if @index}}
<div class=""></div>
{{/if}}
{{/each}}
But how do I add a condition to the if statement which only evaluates to true
for every second item?
I'm stuck trying to implement this functionality this is my approach so far:
function hbsHelpers(hbs) {
return hbs.create({
helpers: { // This was missing
isEven: function(value, options) {
},
// More helpers...
},
});
}