/** * Render template. * * @param View $template Template view instance. * @param array|DataCollection $data Data. * @return string * * @throws ConfigurationException */ public function render(View $template, array $data = array()) { if (!empty($this->data)) { // @codeCoverageIgnore $data = array_merge($this->data, $data); // @codeCoverageIgnore } // @codeCoverageIgnore // Path $path = $template->getFullPath(); // Declare all data vars local if possible foreach ($data as $name => $value) { ${$name} = $value; } // Require and stop with OB. ob_start(); require $path; return ob_get_clean(); }
/** * Render template. * * @param View $template Template view instance. * @param array|DataCollection $data Data. * * @return string|void * * @throws ConfigurationException * @throws FileNotFoundException * @throws RendererException */ public function render(View $template, array $data = array()) { if (!empty($this->data)) { $data = array_merge($this->data, $data); } // Load file into string $source = file_get_contents($template->getFullPath()); if ($source === false) { throw new FileNotFoundException("View file '" . $template->getFullPath() . "' is not found!"); // @codeCoverageIgnore } return $this->mustache->render($source, $data); }