1234567891011121314151617181920212223242526 |
- <?php
- class TwigWrapper
- {
- public function __construct()
- {
- Twig_Autoloader::register();
- $allLoaders = new Twig_Loader_Chain();
- $viewLoader = new Twig_Loader_Filesystem(VIEW_ROOT);
- $deployLoader = new Twig_Loader_Filesystem(TEMPLATE_ROOT);
- $allLoaders->addLoader($viewLoader);
- $allLoaders->addLoader($deployLoader);
-
- $this->twig = new Twig_Environment($allLoaders, array());
- $this->twig->addFilter('var_dump', new Twig_Filter_Function('var_dump'));
- }
- public function render($file, $options)
- {
- $options['all'] = array_keys($options);
- return $this->twig->render($file, $options);
- }
- }
- class TwigClassException extends Exception
- {}
|