From bbc2308efbf35330bd4e5c6af18beec11b8f7405 Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Thu, 29 May 2014 16:14:49 +0100 Subject: [PATCH] Simplify handling of optional count argument. --- src/mkws-handlebars.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mkws-handlebars.js b/src/mkws-handlebars.js index 537779e..999c138 100644 --- a/src/mkws-handlebars.js +++ b/src/mkws-handlebars.js @@ -13,8 +13,9 @@ Handlebars.registerHelper('mkws-paragraphs', function(obj, count) { // 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; + if (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, ''), '

'); -- 1.7.10.4