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:
committed by
Alan Johnson
parent
40e03aafee
commit
03cadf8e76
+1
-1
@@ -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 + " )";
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user