diff -r 000000000000 -r 7f95f8617b0b vendor/twig/lib/Twig/Node/Expression/Function.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/twig/lib/Twig/Node/Expression/Function.php Sat Sep 24 15:40:41 2011 +0200 @@ -0,0 +1,49 @@ + $name, 'arguments' => $arguments), array(), $lineno); + } + + public function compile(Twig_Compiler $compiler) + { + $function = $compiler->getEnvironment()->getFunction($this->getNode('name')->getAttribute('name')); + if (false === $function) { + throw new Twig_Error_Syntax(sprintf('The function "%s" does not exist', $this->getNode('name')->getAttribute('name')), $this->getLine()); + } + + $compiler + ->raw($function->compile().'(') + ->raw($function->needsEnvironment() ? '$this->env' : '') + ; + + if ($function->needsContext()) { + $compiler->raw($function->needsEnvironment() ? ', $context' : '$context'); + } + + $first = true; + foreach ($this->getNode('arguments') as $node) { + if (!$first) { + $compiler->raw(', '); + } else { + if ($function->needsEnvironment() || $function->needsContext()) { + $compiler->raw(', '); + } + $first = false; + } + $compiler->subcompile($node); + } + + $compiler->raw(')'); + } +}