2
0
mirror of https://github.com/thumbsup/thumbsup synced 2024-11-15 18:12:46 +00:00

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}}
This commit is contained in:
Romain Prieto 2016-10-16 22:26:12 +11:00
parent 5553ab0c9b
commit d8f8a0c1fe

View File

@ -51,6 +51,15 @@ exports.create = function(options) {
return ret; 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 // utility helper
// render the correct download path based on user options // render the correct download path based on user options
handlebars.registerHelper('download', function(file) { handlebars.registerHelper('download', function(file) {