Fix rendering of paths that resolve to zero

Fixes #820
This commit is contained in:
kpdecker
2014-07-12 11:43:45 -05:00
parent c90cfe247c
commit 1fb7b51ee6
2 changed files with 5 additions and 1 deletions
@@ -369,7 +369,7 @@ JavaScriptCompiler.prototype = {
return ' != null ? ' + lookup + ' : ' + current;
} else {
// Otherwise we can use generic falsy handling
return ' && ' + lookup;
return ' != null && ' + lookup;
}
}, true);
}
+4
View File
@@ -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');