Fix missing parameters for pathed mustaches

Fixes #658
This commit is contained in:
kpdecker
2014-01-17 22:56:40 -06:00
parent d4cfe90959
commit 33921beaa0
4 changed files with 37 additions and 7 deletions
+5 -5
View File
@@ -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
+3 -1
View File
@@ -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);
}
},
@@ -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) {