Mercurial > hg > dml-open-vis
view src/Kachkaev/JstmplBundle/Twig/JstmplExtension.php @ 0:493bcb69166c
added public content
author | Daniel Wolff |
---|---|
date | Tue, 09 Feb 2016 20:54:02 +0100 |
parents | |
children |
line wrap: on
line source
<?php namespace Kachkaev\JstmplBundle\Twig; use Symfony\Component\DependencyInjection\ContainerInterface; use Twig_Extension; use Twig_Function_Method; class JstmplExtension extends Twig_Extension { protected $container; public function __construct(ContainerInterface $container) { $this->container = $container; } /** * @inheritdoc */ public function getFunctions() { $functions = array(); $mappings = array( 'tmpl_path' => 'getTmplPath', ); foreach($mappings as $twigFunction => $method) { $functions[$twigFunction] = new Twig_Function_Method($this, $method); } $safeMappings = array( ); foreach($safeMappings as $twigFunction => $method) { $functions[$twigFunction] = new Twig_Function_Method($this, $method, array ('is_safe' => array('html'))); } return $functions; } public function getTokenParsers() { return array( new JstmplTokenParser() ); } public function getName() { return 'TmplExtension'; } public function getTmplPath($name) { return "/js/tmpl/$name.js"; } }