refactor(parse): simplify the Parser's filter function

This commit is contained in:
Lucas Galfaso
2014-05-21 21:37:59 -03:00
committed by rodyhaddad
parent f7a0a386ee
commit 6fb121e64c

View File

@@ -542,21 +542,17 @@ Parser.prototype = {
var token = this.expect();
var fn = this.$filter(token.text);
var argsFn = [];
while (true) {
if ((token = this.expect(':'))) {
argsFn.push(this.expression());
} else {
var fnInvoke = function(self, locals, input) {
var args = [input];
for (var i = 0; i < argsFn.length; i++) {
args.push(argsFn[i](self, locals));
}
return fn.apply(self, args);
};
return function() {
return fnInvoke;
};
while(this.expect(':')) {
argsFn.push(this.expression());
}
return valueFn(fnInvoke);
function fnInvoke(self, locals, input) {
var args = [input];
for (var i = 0; i < argsFn.length; i++) {
args.push(argsFn[i](self, locals));
}
return fn.apply(self, args);
}
},