Permalink
Browse files

function replacement can now be done using just a value instead of a …

…callback function
  • Loading branch information...
1 parent 0174978 commit fe4b39d66d94dad6be448f6f7d6447fd2b3d249a @dresende committed Aug 25, 2011
Showing with 10 additions and 6 deletions.
  1. +10 −6 lib/ast-transformer.js
@@ -77,14 +77,18 @@ Transformer.prototype.__crawlAST = function (ast, prefix) {
var functionCall = getCallPath(ast[1]);
if (functionCall !== null && this.functionCalls.hasOwnProperty(functionCall)) {
- var args = [];
+ if (typeof this.functionCalls[functionCall] == "function") {
+ var args = [];
- for (var i = 0; i < ast[2].length; i++) {
- // @TODO: check parameter type
- args.push(convertASTToVar(ast[2][i]));
- }
+ for (var i = 0; i < ast[2].length; i++) {
+ // @TODO: check parameter type
+ args.push(convertASTToVar(ast[2][i]));
+ }
- ast = convertVarToAST(this.functionCalls[functionCall].apply(null, args));
+ ast = convertVarToAST(this.functionCalls[functionCall].apply(null, args));
+ } else {
+ ast = convertVarToAST(this.functionCalls[functionCall]);
+ }
break;
}

0 comments on commit fe4b39d

Please sign in to comment.