Skip to content

Commit

Permalink
Fix rendering of paths that resolve to zero
Browse files Browse the repository at this point in the history
Fixes #820
  • Loading branch information
kpdecker committed Jul 12, 2014
1 parent c90cfe2 commit 1fb7b51
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/handlebars/compiler/javascript-compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ JavaScriptCompiler.prototype = {
return ' != null ? ' + lookup + ' : ' + current;
} else {
// Otherwise we can use generic falsy handling
return ' && ' + lookup;
return ' != null && ' + lookup;
}
}, true);
}
Expand Down
4 changes: 4 additions & 0 deletions spec/regressions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 1fb7b51

Please sign in to comment.