diff --git a/lib/comparison.js b/lib/comparison.js index a69c5c31..0efb1a78 100644 --- a/lib/comparison.js +++ b/lib/comparison.js @@ -277,7 +277,7 @@ helpers.ifEven = function(num, options) { */ helpers.ifNth = function(a, b, options) { - if (++b % a === 0) { + if (utils.isNumber(a) && utils.isNumber(b) && b % a === 0) { return options.fn(this); } return options.inverse(this); diff --git a/test/comparison.js b/test/comparison.js index 4c51d135..16df0892 100644 --- a/test/comparison.js +++ b/test/comparison.js @@ -307,7 +307,7 @@ describe('comparison', function() { describe('ifNth', function() { it('should render a custom class on even rows', function() { - var source = '{{#each items}}
{{name}}
{{/each}}'; + var source = '{{#each items}}{{name}}{{/each}}'; var fn = hbs.compile(source); var context = { items: [ @@ -319,11 +319,11 @@ describe('comparison', function() { ] }; assert(fn(context), [ - '
Philip J. Fry
', + '
Philip J. Fry
', '
Turanga Leela
', - '
Bender Bending Rodriguez
', + '
Bender Bending Rodriguez
', '
Amy Wong
', - '
Hermes Conrad
' + '
Hermes Conrad
' ].join('')); }); });