Mercurial > hg > dml-open-vis
comparison 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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:493bcb69166c |
---|---|
1 <?php | |
2 namespace Kachkaev\JstmplBundle\Twig; | |
3 | |
4 use Symfony\Component\DependencyInjection\ContainerInterface; | |
5 use Twig_Extension; | |
6 use Twig_Function_Method; | |
7 | |
8 class JstmplExtension extends Twig_Extension | |
9 { | |
10 protected $container; | |
11 | |
12 public function __construct(ContainerInterface $container) | |
13 { | |
14 $this->container = $container; | |
15 } | |
16 | |
17 /** | |
18 * @inheritdoc | |
19 */ | |
20 public function getFunctions() | |
21 { | |
22 $functions = array(); | |
23 | |
24 $mappings = array( | |
25 'tmpl_path' => 'getTmplPath', | |
26 ); | |
27 | |
28 foreach($mappings as $twigFunction => $method) { | |
29 $functions[$twigFunction] = new Twig_Function_Method($this, $method); | |
30 } | |
31 | |
32 $safeMappings = array( | |
33 ); | |
34 | |
35 foreach($safeMappings as $twigFunction => $method) { | |
36 $functions[$twigFunction] = new Twig_Function_Method($this, $method, array ('is_safe' => array('html'))); | |
37 } | |
38 | |
39 return $functions; | |
40 } | |
41 | |
42 public function getTokenParsers() | |
43 { | |
44 return array( | |
45 new JstmplTokenParser() | |
46 ); | |
47 } | |
48 | |
49 public function getName() | |
50 { | |
51 return 'TmplExtension'; | |
52 } | |
53 | |
54 public function getTmplPath($name) | |
55 { | |
56 return "/js/tmpl/$name.js"; | |
57 } | |
58 } |