Skip to content

Commit

Permalink
Merge pull request #152 from EriksRemess/patch-1
Browse files Browse the repository at this point in the history
Joining block contents with newline
  • Loading branch information
jtwebman authored Jan 10, 2019
2 parents e3017d4 + 799aa4a commit 9aa1275
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/hbs.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@ ExpressHbs.prototype.express3 = function(options) {
if (val === undefined && typeof options.fn === 'function') {
val = options.fn(this);
}
if (Array.isArray(val)) {
val = val.join('\n');
}
return val;
});

Expand Down
17 changes: 17 additions & 0 deletions test/issues.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,3 +429,20 @@ describe('issue-144', function() {
});
});
});

describe('issue-153', function() {
var dirname = path.join(__dirname, 'issues/153');
it('should concat contentFor blocks with newline', function(done) {
var check = function (err, html) {
if (err) {
done(err);
}
assert.equal('1\n2', html.trim());
done();
}
var hb = hbs.create()
var render = hb.express3({});
var locals = H.createLocals('express3', dirname, { });
render(dirname + '/index.hbs', locals, check);
});
});
3 changes: 3 additions & 0 deletions test/issues/153/index.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{#contentFor "testBlock"}}1{{/contentFor}}
{{#contentFor "testBlock"}}2{{/contentFor}}
{{{block "testBlock"}}}

0 comments on commit 9aa1275

Please sign in to comment.