Created
July 27, 2015 17:11
-
-
Save yankeyhotel/d15b3729e9afa442a4c9 to your computer and use it in GitHub Desktop.
Add an index to #each loop
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
/** | |
* Add an index to each loop | |
*/ | |
UI.registerHelper('indexedArray', function(context, options) { | |
if (context) { | |
return context.map(function(item, index) { | |
item._index = index + 1; | |
return item; | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
via: http://evgenys-blog.blogspot.com/2014/06/index-in-each-expression-meteor.html