Use options register for blockHelperMissing

This commit is contained in:
kpdecker
2013-01-20 17:30:40 -06:00
parent 956b0a62a6
commit b3a39ccefd
+9 -4
View File
@@ -203,14 +203,16 @@ Handlebars.JavaScriptCompiler = function() {};
},
ambiguousMustache: function(mustache, program, inverse) {
var id = mustache.id, name = id.parts[0];
var id = mustache.id,
name = id.parts[0],
isBlock = program != null || inverse != null;
this.opcode('getContext', id.depth);
this.opcode('pushProgram', program);
this.opcode('pushProgram', inverse);
this.opcode('invokeAmbiguous', name);
this.opcode('invokeAmbiguous', name, isBlock);
},
simpleMustache: function(mustache) {
@@ -555,6 +557,9 @@ Handlebars.JavaScriptCompiler = function() {};
var current = this.topStack();
params.splice(1, 0, current);
// Use the options value generated from the invocation
params[params.length-1] = 'options';
this.source.push("if (!" + this.lastHelper + ") { " + current + " = blockHelperMissing.call(" + params.join(", ") + "); }");
},
@@ -812,11 +817,11 @@ Handlebars.JavaScriptCompiler = function() {};
// This operation emits more code than the other options,
// and can be avoided by passing the `knownHelpers` and
// `knownHelpersOnly` flags at compile-time.
invokeAmbiguous: function(name) {
invokeAmbiguous: function(name, helperCall) {
this.context.aliases.functionType = '"function"';
this.pushStackLiteral('{}');
var helper = this.setupHelper(0, name);
var helper = this.setupHelper(0, name, helperCall);
var helperName = this.lastHelper = this.nameLookup('helpers', name, 'helper');