Skip to content

Commit

Permalink
Merge pull request #16 from gastonrobledo/master
Browse files Browse the repository at this point in the history
Update from fork.
  • Loading branch information
gastonrobledo committed Sep 7, 2020
2 parents 67cc719 + c54e054 commit 244eeca
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/handlebars/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ function template(templateSpec, env, callback) {
}
if (result != null) {
if (options.indent) {
if(Utils.isPromise(result)) {
if (Utils.isPromise(result)) {
result = await result
}
const lines = result.split('\n')
const lines = result ? result.split('\n') : []
for (let i = 0, l = lines.length; i < l; i++) {
if (!lines[i] && i + 1 === l) {
break
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "handlebars-stream-render",
"version": "1.1.6",
"version": "1.1.7",
"description": "Handlebars modification to work with stream outputs",
"keywords": [
"handlebars",
Expand Down
22 changes: 22 additions & 0 deletions tests/test_helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -544,4 +544,26 @@ describe('Test stream results', () => {
stream.end()
})


it('test with deep partial template', (done) => {
const hbs = new HandlebarsStream([{
name: 'test_deep',
content: '{{#each names}}<i>{{name}}</i>{{/each}}'
},
{
name: 'test',
content: '<div>{{> test_deep}}</div>'
}
]),
expected = 'test <p><div><i>gaston</i><i>pedro</i></div></p> test'
hbs.compile('test <p>{{> test}}</p> test', { names: [{ name: 'gaston' }, { name: 'pedro' }] })
let result = ''
hbs.on('data', (block) => {
result += block.toString()
}).on('end', () => {
assert(result.trim() === expected.trim())
done()
})
})

})

0 comments on commit 244eeca

Please sign in to comment.