Я использую handlebars.js для моего механизма шаблонов и хочу сделать отображение условного сегмента только в том случае, если это последний элемент массива, содержащийся в объекте конфигурации шаблонов.
{
columns: [{<obj>},{<obj>},{<obj>},{<obj>},{<obj>}]
}
Я уже потянул помощника, чтобы выполнить сравнение равенства/больше/меньше, чем сравнение, и имел успех идентифицировать исходный элемент таким образом, но мне не удавалось получить доступ к моей длине массива.
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}}"
Кто-нибудь знает ярлык, другой подход и некоторую поддержку рулей, которая не даст мне оторваться от механизма handlebars.js, чтобы определить лучший курс?