Created
January 5, 2013 04:25
-
-
Save zwily/4459743 to your computer and use it in GitHub Desktop.
making iterating in handlebars suck less
This file contains hidden or 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
# Used like this: | |
# {{#foreach "zone" in data.availability_zones}} | |
# <th>{{zone}}</th> | |
# {{/foreach}} | |
Handlebars.registerHelper "foreach", (keyword, blah, collection, ctx) -> | |
buffer = "" | |
copy = _.clone(this) | |
_.each collection, (i) -> | |
copy[keyword] = i | |
buffer += ctx.fn(copy) | |
buffer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment