Add handy Handlebars helper to repeat a block N times

Usage: {{#times 4}}hello{{/times}
Can also use any variables in context, e.g. {{#times things.length}}
pull/47/head
Romain Prieto 8 years ago
parent 5553ab0c9b
commit d8f8a0c1fe

@ -51,6 +51,15 @@ exports.create = function(options) {
return ret;
});
// utility helper
// execute the child block N times
handlebars.registerHelper('times', function(n, block) {
var accum = '';
for(var i = 0; i < n; ++i)
accum += block.fn(i);
return accum;
});
// utility helper
// render the correct download path based on user options
handlebars.registerHelper('download', function(file) {

Loading…
Cancel
Save