diff options
author | kpdecker <kpdecker@gmail.com> | 2014-07-12 11:43:45 -0500 |
---|---|---|
committer | kpdecker <kpdecker@gmail.com> | 2014-07-12 11:43:45 -0500 |
commit | 1fb7b51ee6bb8f4a2e395821a4648333a699a982 (patch) | |
tree | 50341e601dcec1e7afd119f0f43bd7ee867d11d1 | |
parent | c90cfe247cf1108f94fd97b4e93a42f4a49d3516 (diff) | |
download | handlebars.js-1fb7b51ee6bb8f4a2e395821a4648333a699a982.zip handlebars.js-1fb7b51ee6bb8f4a2e395821a4648333a699a982.tar.gz handlebars.js-1fb7b51ee6bb8f4a2e395821a4648333a699a982.tar.bz2 |
Fix rendering of paths that resolve to zero
Fixes #820
-rw-r--r-- | lib/handlebars/compiler/javascript-compiler.js | 2 | ||||
-rw-r--r-- | spec/regressions.js | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/lib/handlebars/compiler/javascript-compiler.js b/lib/handlebars/compiler/javascript-compiler.js index b2baad4..2d4b115 100644 --- a/lib/handlebars/compiler/javascript-compiler.js +++ b/lib/handlebars/compiler/javascript-compiler.js @@ -369,7 +369,7 @@ JavaScriptCompiler.prototype = { return ' != null ? ' + lookup + ' : ' + current; } else { // Otherwise we can use generic falsy handling - return ' && ' + lookup; + return ' != null && ' + lookup; } }, true); } diff --git a/spec/regressions.js b/spec/regressions.js index 214a142..c633a21 100644 --- a/spec/regressions.js +++ b/spec/regressions.js @@ -122,6 +122,10 @@ describe('Regressions', function() { shouldCompileTo('{{#foo}} This is {{bar}} ~ {{/foo}}', {foo: 0, bar: 'OK'}, ' This is ~ '); }); + it('GH-820: zero pathed rendering', function() { + shouldCompileTo('{{foo.bar}}', {foo: 0}, ''); + }); + if (Handlebars.AST) { it("can pass through an already-compiled AST via compile/precompile", function() { equal(Handlebars.compile(new Handlebars.AST.ProgramNode([ new Handlebars.AST.ContentNode("Hello")]))(), 'Hello'); |