Exemplo n.º 1
0
 /**
  * Render a template or a view model
  *
  * @param string|array|ViewModel  $template
  * @param array         $variables
  *
  * @return string
  */
 public function render($template, array $variables = array())
 {
     if ($template instanceof ViewModel) {
         $template->setVariables($variables);
     } elseif (is_array($template)) {
         $section = isset($template['section']) ? $template['section'] : Pi::engine()->application()->getSection();
         $module = !empty($template['module']) ? $template['module'] : Pi::service('module')->current();
         $file = $template['file'];
         $template = $module . ':' . ($section ? $section . '/' : '') . $file;
     }
     $content = $this->getViewManager()->getRenderer()->render($template, $variables);
     return $content;
 }