From 32d7e52182414ae48ff82d4456d982049f0203a5 Mon Sep 17 00:00:00 2001 From: tomhuda Date: Fri, 25 Feb 2011 23:01:11 -0800 Subject: [PATCH] Helpers take precedence over context properties with the same name. This is useful in scenarios where your context object is inherited from another system (such as a framework or JSON API) that may contain properties that conflict with helpers you explicitly define. --- lib/handlebars/vm.js | 20 +++++++++++++------- spec/qunit_spec.js | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 7 deletions(-) diff --git a/lib/handlebars/vm.js b/lib/handlebars/vm.js index 3f44a36f..1c2b4eef 100644 --- a/lib/handlebars/vm.js +++ b/lib/handlebars/vm.js @@ -8,7 +8,7 @@ Handlebars.JavaScriptCompiler = function() {}; Compiler.OPCODE_MAP = { appendContent: 1, getContext: 2, - lookupWithFallback: 3, + lookupWithHelpers: 3, lookup: 4, append: 5, invokeMustache: 6, @@ -25,7 +25,7 @@ Handlebars.JavaScriptCompiler = function() {}; Compiler.MULTI_PARAM_OPCODES = { appendContent: 1, getContext: 1, - lookupWithFallback: 1, + lookupWithHelpers: 1, lookup: 1, invokeMustache: 2, pushString: 1, @@ -201,7 +201,7 @@ Handlebars.JavaScriptCompiler = function() {}; this.opcode('getContext', id.depth); - this.opcode('lookupWithFallback', id.parts[0] || null); + this.opcode('lookupWithHelpers', id.parts[0] || null); for(var i=1, l=id.parts.length; i