Skip to content

Instantly share code, notes, and snippets.

@yankeyhotel
Created July 27, 2015 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yankeyhotel/d15b3729e9afa442a4c9 to your computer and use it in GitHub Desktop.
Save yankeyhotel/d15b3729e9afa442a4c9 to your computer and use it in GitHub Desktop.
Add an index to #each loop
/**
* 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