Disambiguate more ahead of time
This commit is contained in:
@@ -168,26 +168,43 @@ Handlebars.JavaScriptCompiler = function() {};
|
|||||||
},
|
},
|
||||||
|
|
||||||
mustache: function(mustache) {
|
mustache: function(mustache) {
|
||||||
var id = mustache.id;
|
var isHelper = mustache.isHelper;
|
||||||
|
var isEligible = mustache.eligibleHelper;
|
||||||
|
var options = this.options;
|
||||||
|
|
||||||
if (!mustache.eligibleHelper) {
|
// if ambiguous, we can possibly resolve the ambiguity now
|
||||||
this.simpleMustache(mustache);
|
if (isEligible && !isHelper) {
|
||||||
} else if (mustache.isHelper) {
|
var name = mustache.id.parts[0];
|
||||||
this.helperMustache(mustache);
|
|
||||||
} else {
|
|
||||||
var params = this.setupStackForMustache(mustache),
|
|
||||||
name = id.parts[0];
|
|
||||||
|
|
||||||
this.opcode('invokeMustache', params.length, mustache.id.original);
|
if (options.knownHelpers[name]) {
|
||||||
|
isHelper = true;
|
||||||
|
} else if (options.knownHelpersOnly) {
|
||||||
|
isEligible = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mustache.escaped && !this.options.noEscape) {
|
if (!isEligible) {
|
||||||
|
this.simpleMustache(mustache);
|
||||||
|
} else if (isHelper) {
|
||||||
|
this.helperMustache(mustache);
|
||||||
|
} else {
|
||||||
|
this.ambiguousMustache(mustache);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(mustache.escaped && !options.noEscape) {
|
||||||
this.opcode('appendEscaped');
|
this.opcode('appendEscaped');
|
||||||
} else {
|
} else {
|
||||||
this.opcode('append');
|
this.opcode('append');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
ambiguousMustache: function(mustache) {
|
||||||
|
var params = this.setupStackForMustache(mustache),
|
||||||
|
id = mustache.id, name = id.parts[0];
|
||||||
|
|
||||||
|
this.opcode('invokeMustache', params.length, id.original);
|
||||||
|
},
|
||||||
|
|
||||||
simpleMustache: function(mustache) {
|
simpleMustache: function(mustache) {
|
||||||
var id = mustache.id;
|
var id = mustache.id;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user