X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=src%2Fmkws-handlebars.js;h=605282f641b4e5ca05078ad5ecc6c99087f9c863;hb=33587b3b07b0e4b8a9ce09d340114ded913722d2;hp=537779e5b21860a9dbb29c7535780746dd153fdb;hpb=94a3083ce79f3cdf185add39bb933d695815b623;p=mkws-moved-to-github.git diff --git a/src/mkws-handlebars.js b/src/mkws-handlebars.js index 537779e..605282f 100644 --- a/src/mkws-handlebars.js +++ b/src/mkws-handlebars.js @@ -12,9 +12,12 @@ Handlebars.registerHelper('mkws-paragraphs', function(obj, count) { var acc = []; // For some reason, Handlebars provides the value - // {"hash":{},"data":{}} for undefined parameters - if (count.hasOwnProperty('hash')) count = undefined; - if (!count || count > obj.length) count = obj.length; + // {"hash":{},"data":{}} for parameters that are not provided. So we + // have to be prepared for actual numbers, explicitly undefined + // values and this dumb magic value. + if (count === undefined || count.hasOwnProperty('hash') || count == 0 || count > obj.length) { + count = obj.length; + } for (var i = 0; i < count; i++) { acc.push('

', obj[i].replace(/\[[0-9,]+\]/g, ''), '

');