TwigWrapper.inc 657 B

1234567891011121314151617181920212223242526
  1. <?php
  2. class TwigWrapper
  3. {
  4. public function __construct()
  5. {
  6. Twig_Autoloader::register();
  7. $allLoaders = new Twig_Loader_Chain();
  8. $viewLoader = new Twig_Loader_Filesystem(VIEW_ROOT);
  9. $deployLoader = new Twig_Loader_Filesystem(TEMPLATE_ROOT);
  10. $allLoaders->addLoader($viewLoader);
  11. $allLoaders->addLoader($deployLoader);
  12. $this->twig = new Twig_Environment($allLoaders, array());
  13. $this->twig->addFilter('var_dump', new Twig_Filter_Function('var_dump'));
  14. }
  15. public function render($file, $options)
  16. {
  17. $options['all'] = array_keys($options);
  18. return $this->twig->render($file, $options);
  19. }
  20. }
  21. class TwigClassException extends Exception
  22. {}