Skip to content

Commit 9aa1275

Browse files
authored
Merge pull request #152 from EriksRemess/patch-1
Joining block contents with newline
2 parents e3017d4 + 799aa4a commit 9aa1275

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

lib/hbs.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,9 @@ ExpressHbs.prototype.express3 = function(options) {
237237
if (val === undefined && typeof options.fn === 'function') {
238238
val = options.fn(this);
239239
}
240+
if (Array.isArray(val)) {
241+
val = val.join('\n');
242+
}
240243
return val;
241244
});
242245

test/issues.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,3 +429,20 @@ describe('issue-144', function() {
429429
});
430430
});
431431
});
432+
433+
describe('issue-153', function() {
434+
var dirname = path.join(__dirname, 'issues/153');
435+
it('should concat contentFor blocks with newline', function(done) {
436+
var check = function (err, html) {
437+
if (err) {
438+
done(err);
439+
}
440+
assert.equal('1\n2', html.trim());
441+
done();
442+
}
443+
var hb = hbs.create()
444+
var render = hb.express3({});
445+
var locals = H.createLocals('express3', dirname, { });
446+
render(dirname + '/index.hbs', locals, check);
447+
});
448+
});

test/issues/153/index.hbs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{{#contentFor "testBlock"}}1{{/contentFor}}
2+
{{#contentFor "testBlock"}}2{{/contentFor}}
3+
{{{block "testBlock"}}}

0 commit comments

Comments
 (0)