Disambiguate more ahead of time
This commit is contained in:
@@ -168,26 +168,43 @@ Handlebars.JavaScriptCompiler = function() {};
|
||||
},
|
||||
|
||||
mustache: function(mustache) {
|
||||
var id = mustache.id;
|
||||
var isHelper = mustache.isHelper;
|
||||
var isEligible = mustache.eligibleHelper;
|
||||
var options = this.options;
|
||||
|
||||
if (!mustache.eligibleHelper) {
|
||||
this.simpleMustache(mustache);
|
||||
} else if (mustache.isHelper) {
|
||||
this.helperMustache(mustache);
|
||||
} else {
|
||||
var params = this.setupStackForMustache(mustache),
|
||||
name = id.parts[0];
|
||||
// if ambiguous, we can possibly resolve the ambiguity now
|
||||
if (isEligible && !isHelper) {
|
||||
var name = mustache.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');
|
||||
} else {
|
||||
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) {
|
||||
var id = mustache.id;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user