I am currently utilizing handlebars.js as my templating engine and am interested in creating a conditional segment that will only display if it happens to be the final item within an array located in the templates configuration object.
{
columns: [{<obj>},{<obj>},{<obj>},{<obj>},{<obj>}]
}
While I have already integrated a helper function for performing equality, greater than, and less than comparisons, I am encountering difficulties in determining the length of the target array.
Handlebars.registerHelper('compare', function(lvalue, rvalue, options) {...})
"{{#each_with_index columns}}"+
"<div class='{{#equal index 0}} first{{/equal}}{{#equal index ../columns.length()}} last{{/equal}}'>"+
"</div>"+
"{{/each_with_index}}"
I am seeking alternative methods, a possible shortcut, or any handlebars tips that could help me avoid having to delve deep into the handlebars.js engine to find an optimal solution. Does anyone have any suggestions?