* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * * @author Fabien Potencier */ class HelpersExtension extends \Twig_Extension { protected $container; public function __construct(ContainerInterface $container) { $this->container = $container; } public function getContainer() { return $this->container; } /** * Returns the token parser instance to add to the existing list. * * @return array An array of Twig_TokenParser instances */ public function getTokenParsers() { return array( // {% javascript 'bundles/blog/js/blog.js' %} new HelperTokenParser('javascript', ' [with ]', 'templating.helper.javascripts', 'add'), // {% javascripts %} new HelperTokenParser('javascripts', '', 'templating.helper.javascripts', 'render'), // {% stylesheet 'bundles/blog/css/blog.css' with ['media': 'screen'] %} new HelperTokenParser('stylesheet', ' [with ]', 'templating.helper.stylesheets', 'add'), // {% stylesheets %} new HelperTokenParser('stylesheets', '', 'templating.helper.stylesheets', 'render'), // {% asset 'css/blog.css' %} new HelperTokenParser('asset', '', 'templating.helper.assets', 'getUrl'), // {% route 'blog_post' with ['id': post.id] %} new HelperTokenParser('route', ' [with ]', 'templating.helper.router', 'generate'), // {% render 'BlogBundle:Post:list' with ['limit': 2], ['alt': 'BlogBundle:Post:error'] %} new HelperTokenParser('render', '