示例#1
0
文件: View.php 项目: yeephp/yeephp
 /**
  * Render a template file
  *
  * NOTE: This method should be overridden by custom view subclasses
  *
  * @param  string $template     The template pathname, relative to the template base directory
  * @param  array  $data         Any additonal data to be passed to the template.
  * @return string               The rendered template
  * @throws \RuntimeException    If resolved template pathname is not a valid file
  */
 protected function render($template, $data = null)
 {
     $templatePathname = $this->getTemplatePathname($template);
     if (!is_file($templatePathname)) {
         throw new \RuntimeException("View cannot render `{$template}` because the template does not exist");
     }
     $data = array_merge($this->data->all(), (array) $data);
     extract($data);
     ob_start();
     require $templatePathname;
     return ob_get_clean();
 }