* 1.4.0
+ * added Twig_Function_Node to allow more complex functions to have their own Node class
* added Twig_Filter_Node to allow more complex filters to have their own Node class
* added Twig_Test_Node to allow more complex tests to have their own Node class
* added a better error message when a template is empty but contain a BOM
return new Twig_Node_Expression_GetAttr($alias['node'], new Twig_Node_Expression_Constant($alias['name'], $line), $args, Twig_TemplateInterface::METHOD_CALL, $line);
}
- return new Twig_Node_Expression_Function($name, $args, $line);
+ $functionMap = $this->parser->getEnvironment()->getFunctions();
+ if (isset($functionMap[$name]) && $functionMap[$name] instanceof Twig_Filter_Node) {
+ $class = $functionMap[$name]->getClass();
+ } else {
+ $class = 'Twig_Node_Expression_Function';
+ }
+
+ return new $class($name, $args, $line);
}
}
--- /dev/null
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2011 Fabien Potencier
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Represents a template function as a node.
+ *
+ * @package twig
+ * @author Fabien Potencier <fabien@symfony.com>
+ */
+class Twig_Function_Node extends Twig_Filter
+{
+ protected $class;
+
+ public function __construct($class, array $options = array())
+ {
+ parent::__construct($options);
+
+ $this->class = $class;
+ }
+
+ public function getClass()
+ {
+ return $this->class;
+ }
+
+ public function compile()
+ {
+ }
+}