diff --git a/lib/handlebars.js b/lib/handlebars.js index 22137012..afa80134 100644 --- a/lib/handlebars.js +++ b/lib/handlebars.js @@ -359,7 +359,7 @@ Handlebars.Compiler.prototype = { } else if (parts.length == 1) { return "(!Handlebars.isEmpty(context['" + parts[0] + "']) ? context['" + parts[0] + "'] : fallback['" + parts[0] + "'])"; } else { - return "(!Handlebars.isEmpty(context) ? context : fallback)"; + return "(!Handlebars.isEmpty(context) ? context : null)"; } }, diff --git a/test/handlebars.js b/test/handlebars.js index d329e4a1..a589ee55 100644 --- a/test/handlebars.js +++ b/test/handlebars.js @@ -110,6 +110,10 @@ test("bad idea nested paths", function() { shouldCompileTo(string, hash, "world world world ", "Same context (.) is ignored in paths"); }); +test("that current context path ({{.}}) doesn't hit fallback", function() { + shouldCompileTo("test: {{.}}", [null, {helper: "awesome"}], "test: "); +}); + test("complex but empty paths", function() { shouldCompileTo("{{person/name}}", {person: {name: null}}, ""); shouldCompileTo("{{person/name}}", {person: {}}, "");