Ejemplo n.º 1
0
 /**
  * @param View $view
  * @throws \Exception
  */
 private function init($view)
 {
     $this->template['engine'] = new Engine(rtrim($view->getPath(), '/'), ltrim($view->getExtension(), '.'));
     foreach ($this->extensions as $extension) {
         is_callable($extension) ? $this->template['engine']->loadExtension(call_user_func($extension)) : $this->template['engine']->loadExtension(new $extension());
     }
 }
Ejemplo n.º 2
0
 /**
  * @param View $view
  * @throws \Exception
  */
 private function init($view)
 {
     if (!is_null($view->getTemplate())) {
         $loader = $this->loadTemplate($view);
     } elseif (!is_null($view->getContent())) {
         $loader = $this->loadContent($view);
     }
     if (isset($loader)) {
         $this->template['loader'] = $loader;
         $this->template['engine'] = new Twig_Environment($loader, array('cache' => $this->options['cache'], 'debug' => $this->options['debug'], 'charset' => $this->options['charset']));
     } else {
         throw new \Exception('Loader not found for Twig template');
     }
 }
Ejemplo n.º 3
0
 /**
  * @param View $view
  * @return null
  */
 public function render(View $view)
 {
     if (!is_null($view->getContent())) {
         return $this->template['engine']->renderContent($view->getContent(), $view->getData());
     } elseif (!is_null($view->getTemplate())) {
         return $this->template['engine']->renderTemplate($view->getFullPath(), $view->getData());
     }
     return null;
 }