AbstractView::render PHP Method

render() public method

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()
    {
        if (!$this->template) {
            throw $this->exception('You should specify template for this object')->addMoreInfo('object', $this->name)->addMoreInfo('spot', $this->spot);
        }
        $this->output($render = $this->template->render());
        if (@$this->debug) {
            echo '<font color="blue">' . htmlspecialchars($render) . '</font>';
        }
    }

Usage Example

Example #1
0
 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;
 }
All Usage Examples Of AbstractView::render