Disambiguate more ahead of time

This commit is contained in:
tomhuda
2012-05-28 14:19:48 -07:00
parent bc5efc1767
commit 3486b530be
+27 -10
View File
@@ -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;