/** * Render the template and layout. * @param array $data * @return string */ public function render(array $data = array()) { try { $this->data($data); unset($data); extract($this->data); ob_start(); if ($this->exists()) { include $this->path(); } else { throw new LogicException('The template "' . $this->name->getName() . '" could not be found at "' . $this->path() . '".'); } $content = ob_get_clean(); if (isset($this->layoutName)) { $layout = $this->engine->make($this->layoutName); $layout->sections = array_merge($this->sections, array('content' => $content)); $content = $layout->render($this->layoutData); } return $content; } catch (LogicException $e) { if (ob_get_length() > 0) { ob_end_clean(); } throw $e; } }
/** * Fetch a rendered template. * @param string $name * @param array $data * @return string */ protected function fetch($name, array $data = array()) { //return $this->engine->render($name, $data); $template = $this->engine->make($name); $template->sections = $this->sections; return $template->render($data); }
/** * Parse php files * * @param string $filename * @return string parsed content */ protected function compileFile($filename) { $template = $this->engine->make($filename); $content = $template->render(); return $content; }
protected function makeTemplate($name) { return $this->templater->make($name); }
/** * @inheritDoc */ public function body(PayloadInterface $payload) { $template = $this->template($payload); $template = $this->engine->make($template); return $this->render($template, $payload); }