KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am leveraging handlebars.js for my templating engine and am looking to make a conditional segment display only if it is the last item in array contained in the templates configuration object. { columns: [{<obj>},{<obj>},{<obj>},{<obj>},{<obj>}] } I've already pulled in a helper to do some equality/greater/less-than comparisons and have had success identifying the initial item this way but have had no luck accessing my target array's length. 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}}" Does anyone know a shortcut, different approach, and some handlebars goodness that will keep me from having to tear into the handlebars.js engine to determine best course?
Tags (comma-separated)
Save Edits
Cancel