{{#each steps}}
{{index}} : {{stepDescription}}
{{/each}}
This is a legitimate need, and even available in Handlebars, using {{@index}}, as you can see in this stackoverflow thread or this issue.
Meteor does not support this option yet (0.8). They even mentioned this issue in their wiki:
Syntax extensions. Handlebars syntax is extremely minimal, and we foresee adding some additional well-chosen extensions over time. (We will also implement the top features of current Handlebars that are missing from Meteor, like #each
that supports objects and lets you access the current index or key.)
This looks promising. But for people who need a solution right now, you can just create a helper that adds an _index property to each item in the array:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UI.registerHelper('indexedArray', function(context, options) { | |
if (context) { | |
return context.map(function(item, index) { | |
item._index = index + 1; | |
return item; | |
}); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{#each indexedArray preperationSteps}} | |
{{_index}} : {{stepDescription}} | |
{{/each}} |
Promising too much can be as cruel as caring too little. See the link below for more info.
ReplyDelete#promising
www.ufgop.org
When I initially commented I clicked the -Notify me when new feedback are added- checkbox and now every time a remark is added I get 4 emails with the same comment. Is there any manner you possibly can remove me from that service? Thanks! casino online
ReplyDelete