diff --git a/helpers/each.js b/helpers/each.js index 502cf94..6a350b8 100644 --- a/helpers/each.js +++ b/helpers/each.js @@ -103,6 +103,7 @@ module.exports = (handlebars) => { if (i === 0) { ret = inverse(this) + ret = [inverse(this)] } return ret.join('') diff --git a/test/test.js b/test/test.js index 030c86a..a87f53c 100644 --- a/test/test.js +++ b/test/test.js @@ -344,6 +344,14 @@ describe('Test async helpers', () => { should.equal(result, expected) }) + it('Test each helper with an empty item list', async () => { + const hbs = asyncHelpers(Handlebars) + + const items = [], + result = await hbs.compile('Devs \n{{#each items}}{{/each}}')({items}) + should.equal(result, 'Devs \n') + }) + it('check version', () => { const hbs = asyncHelpers(Handlebars) should(hbs.ASYNC_VERSION).equal(require('../package.json').version)