Skip to content

Commit 783a1d5

Browse files
committed
Coerce noEscape-statements to a string
Fixes #1838
1 parent 520e1d5 commit 783a1d5

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/handlebars/compiler/javascript-compiler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ JavaScriptCompiler.prototype = {
426426
if (this.isInline()) {
427427
this.replaceStack(current => [' != null ? ', current, ' : ""']);
428428

429-
this.pushSource(this.appendToBuffer(this.popStack()));
429+
this.pushSource(this.appendToBuffer([this.popStack(), '+', "''"]));
430430
} else {
431431
let local = this.popStack();
432432
this.pushSource([

spec/javascript-compiler.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ describe('javascript-compiler api', function() {
3434
.toCompileTo('food');
3535
});
3636
});
37+
3738
describe('#compilerInfo', function() {
3839
var $superCheck, $superInfo;
3940
beforeEach(function() {
@@ -58,6 +59,7 @@ describe('javascript-compiler api', function() {
5859
.toCompileTo('food ');
5960
});
6061
});
62+
6163
describe('buffer', function() {
6264
var $superAppend, $superCreate;
6365
beforeEach(function() {
@@ -116,4 +118,13 @@ describe('javascript-compiler api', function() {
116118
});
117119
});
118120
});
121+
122+
describe('options', function() {
123+
it('should append `noEscape` statements as string', function() {
124+
expectTemplate('{{a}}{{b}}')
125+
.withCompileOptions({ noEscape: true })
126+
.withInput({ a: 1, b: 1 })
127+
.toCompileTo('11');
128+
});
129+
});
119130
});

0 commit comments

Comments
 (0)