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) { 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;