diff options
author | kpdecker <kpdecker@gmail.com> | 2013-01-20 17:30:40 -0600 |
---|---|---|
committer | kpdecker <kpdecker@gmail.com> | 2013-01-20 17:30:40 -0600 |
commit | b3a39ccefd2d00428ace05b172f9faf8fd081052 (patch) | |
tree | 002ce937bc30cb8b0681b11aabea50d41a670bfb /lib/handlebars/compiler/compiler.js | |
parent | 956b0a62a6634bffde1054890b8ebaf0724ac6df (diff) | |
download | handlebars.js-b3a39ccefd2d00428ace05b172f9faf8fd081052.zip handlebars.js-b3a39ccefd2d00428ace05b172f9faf8fd081052.tar.gz handlebars.js-b3a39ccefd2d00428ace05b172f9faf8fd081052.tar.bz2 |
Use options register for blockHelperMissing
Diffstat (limited to 'lib/handlebars/compiler/compiler.js')
-rw-r--r-- | lib/handlebars/compiler/compiler.js | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/handlebars/compiler/compiler.js b/lib/handlebars/compiler/compiler.js index a98728d..4742fa8 100644 --- a/lib/handlebars/compiler/compiler.js +++ b/lib/handlebars/compiler/compiler.js @@ -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'); |