Created
September 21, 2013 15:46
-
-
Save zoghal/6651728 to your computer and use it in GitHub Desktop.
My Ember Handlebars Helper Collection
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
/* | |
{{loop countroller.count}} | |
{{name}} | |
{{/loop}} | |
*/ | |
Ember.Handlebars.registerHelper('loop', function(property, options) { | |
var out = ""; | |
var count = Ember.get(this, property); | |
if(Ember.typeOf(count) === 'number' && count >= 1 ){ | |
while (count--) { | |
out+= options.fn(this); | |
} | |
} | |
return new Handlebars.SafeString(out); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment