diff --git a/lib/array.js b/lib/array.js index c862e992..8c498f1d 100644 --- a/lib/array.js +++ b/lib/array.js @@ -57,7 +57,7 @@ helpers.arrayify = function(value) { helpers.before = function(array, n) { if (util.isUndefined(array)) return ''; - return array.slice(0, -n); + return array.slice(0, n); }; /** @@ -617,7 +617,7 @@ helpers.withAfter = function(array, idx, options) { helpers.withBefore = function(array, idx, options) { if (!Array.isArray(array)) return ''; - array = array.slice(0, -idx); + array = array.slice(0, idx); var result = ''; for (var i = 0; i < array.length; i++) { diff --git a/test/array.js b/test/array.js index d665e0be..aaf39c03 100644 --- a/test/array.js +++ b/test/array.js @@ -38,12 +38,12 @@ describe('array', function() { assert.equal(hbs.compile('{{before}}')(), ''); }); it('should return all of the items in an array before the given index', function() { - var fn = hbs.compile('{{before array 5}}'); + var fn = hbs.compile('{{before array 3}}'); assert.equal(fn(context), 'a,b,c'); }); it('should return all of the items in an array before the specified count', function() { - var fn = hbs.compile('{{before array 5}}'); + var fn = hbs.compile('{{before array 3}}'); assert.equal(fn(context), 'a,b,c'); }); }); @@ -396,7 +396,7 @@ describe('array', function() { describe('withBefore', function() { it('should use all of the items in an array before the specified count', function() { - var fn = hbs.compile('{{#withBefore array 5}}<{{this}}>{{/withBefore}}'); + var fn = hbs.compile('{{#withBefore array 3}}<{{this}}>{{/withBefore}}'); assert.equal(fn(context), ''); }); });