diff options
Diffstat (limited to 'lib/handlebars/compiler')
-rw-r--r-- | lib/handlebars/compiler/ast.js | 10 | ||||
-rw-r--r-- | lib/handlebars/compiler/compiler.js | 4 | ||||
-rw-r--r-- | lib/handlebars/compiler/javascript-compiler.js | 2 |
3 files changed, 9 insertions, 7 deletions
diff --git a/lib/handlebars/compiler/ast.js b/lib/handlebars/compiler/ast.js index 8fa6495..6789883 100644 --- a/lib/handlebars/compiler/ast.js +++ b/lib/handlebars/compiler/ast.js @@ -83,14 +83,14 @@ var AST = { var id = this.id = rawParams[0]; var params = this.params = rawParams.slice(1); - // a mustache is an eligible helper if: - // * its id is simple (a single part, not `this` or `..`) - var eligibleHelper = this.eligibleHelper = id.isSimple; - // a mustache is definitely a helper if: // * it is an eligible helper, and // * it has at least one parameter or hash segment - this.isHelper = eligibleHelper && (params.length || hash); + this.isHelper = params.length || hash; + + // a mustache is an eligible helper if: + // * its id is simple (a single part, not `this` or `..`) + this.eligibleHelper = this.isHelper || id.isSimple; // if a mustache is an eligible helper but not a definite // helper, it is ambiguous, and will be resolved in a later diff --git a/lib/handlebars/compiler/compiler.js b/lib/handlebars/compiler/compiler.js index 83eca24..3f7aa3b 100644 --- a/lib/handlebars/compiler/compiler.js +++ b/lib/handlebars/compiler/compiler.js @@ -265,13 +265,15 @@ Compiler.prototype = { helperSexpr: function(sexpr, program, inverse) { var params = this.setupFullMustacheParams(sexpr, program, inverse), - name = sexpr.id.parts[0]; + id = sexpr.id, + name = id.parts[0]; if (this.options.knownHelpers[name]) { this.opcode('invokeKnownHelper', params.length, name); } else if (this.options.knownHelpersOnly) { throw new Exception("You specified knownHelpersOnly, but used the unknown helper " + name, sexpr); } else { + this.ID(id); this.opcode('invokeHelper', params.length, name, sexpr.isRoot); } }, diff --git a/lib/handlebars/compiler/javascript-compiler.js b/lib/handlebars/compiler/javascript-compiler.js index 8ca0116..96a8a0e 100644 --- a/lib/handlebars/compiler/javascript-compiler.js +++ b/lib/handlebars/compiler/javascript-compiler.js @@ -503,8 +503,8 @@ JavaScriptCompiler.prototype = { this.context.aliases.helperMissing = 'helpers.helperMissing'; this.useRegister('helper'); + var nonHelper = this.popStack(); var helper = this.setupHelper(paramSize, name); - var nonHelper = this.nameLookup('depth' + this.lastContext, name, 'context'); var lookup = 'helper = ' + helper.name + ' || ' + nonHelper + ' || helperMissing'; if (helper.paramsInit) { |