For most views, rendering the $this->template would be sufficient.
If your view requires to do some heavy-duty work, please be sure to do
it inside render() method. This way would save some performance in cases
when your object is not being rendered.
render method relies on method output(), which appeends HTML chunks
to the parent's template.
public render ( ) |
public function render() { # make sure we have a template if ($this->template === false) { throw new TemplateUndefined(); } parent::render(); # unpack the props extract($this->props); # trap the buffer ob_start(); # include the template require \options('views') . '/' . $this->template . '.' . $this->extension; # get the buffer contents $parsed = ob_get_contents(); # clean the buffer ob_clean(); # if there is a layout if ($this->layout) { # push the content into the layout $content_for_layout = $parsed; # include the template include \options('views') . '/' . $this->layout . "." . $this->extension; # get the buffer contents $parsed = ob_get_contents(); } # close the output buffer ob_end_clean(); # echo the result echo $parsed; }
function render() { $c = $this->template->get('current'); $this->template->del('current'); $parts = explode('_', $this->api->page); $matched = false; while ($parts) { $tag = implode('_', $parts); if ($this->template->is_set('current_' . $tag)) { $this->template->trySet('current_' . $tag, $c); $matched = true; } array_pop($parts); } if (!$matched) { $this->template->set('current', $c); } parent::render(); }
public function render() { # make sure we have a template if ($this->template === false) { throw new TemplateUndefined(); } parent::render(); # unpack the props extract($this->props); # trap the buffer ob_start(); # include the template $f = $this->template_dir . DIRECTORY_SEPARATOR . $this->template . '.' . $this->extension; if (!file_exists($f)) { throw new TemplateFileNotFound(); } else { require $f; } # get the buffer contents $parsed = ob_get_contents(); # clean the buffer ob_clean(); # if there is a layout if ($this->layout) { # push the content into the layout $yield = $parsed; # include the template include $this->template_dir . DIRECTORY_SEPARATOR . $this->layout . '.' . $this->extension; # get the buffer contents $parsed = ob_get_contents(); } # close the output buffer ob_end_clean(); # echo the result echo $parsed; }
function render() { $this->template->set($this->properties); parent::render(); }
public function render() { parent::render(); echo json_encode($this->props); }