Fix exception when context value is empty string

An exception was being thrown due to the empty string '' being treated
as a non-existent context value.  When the empty string was encountered
as a nested value in the context it caused the fallback to be accessed
instead, and due to the non-existent nesting property it threw an
exception.
This commit is contained in:
Jason Davies
2010-09-19 05:49:38 +08:00
committed by Alan Johnson
parent 40e03aafee
commit 03cadf8e76
2 changed files with 3 additions and 1 deletions
+1 -1
View File
@@ -340,7 +340,7 @@ Handlebars.Compiler.prototype = {
if (depth > 0) {
return "( stack[stack.length - " + depth + "]" + paramExpr + ")";
} else {
return "( context" + paramExpr + " || fallback" + paramExpr + " )";
return "( context" + paramExpr + " != null ? context" + paramExpr + " : fallback" + paramExpr + " )";
}
},