lithium\template\view\adapter\File::render PHP Method

render() public method

Renders content from a template file provided by template().
public render ( string $template, array | string $data = [], array $options = [] ) : string
$template string
$data array | string
$options array
return string
    public function render($template, $data = array(), array $options = array())
    {
        $defaults = array('context' => array());
        $options += $defaults;
        $this->_context = $options['context'] + $this->_context;
        $this->_data = (array) $data + $this->_vars;
        $this->_options = $options;
        $template__ = $template;
        unset($options, $template, $defaults, $data);
        if ($this->_config['extract']) {
            extract($this->_data, EXTR_OVERWRITE);
        } elseif ($this->_view) {
            extract((array) $this->_view->outputFilters, EXTR_OVERWRITE);
        }
        ob_start();
        include $template__;
        return ob_get_clean();
    }

Usage Example

Ejemplo n.º 1
0
 public function testRenderingWithNoExtraction()
 {
     $file = new File(array('extract' => false));
     $this->expectException('Undefined variable: foo');
     $content = $file->render("{$this->_path}/template1.html.php", array('foo' => 'bar'));
     $this->assertEmpty($content);
     $content = $file->render("{$this->_path}/template2.html.php", array('foo' => 'bar'));
     $this->assertEqual('bar', $content);
 }
All Usage Examples Of lithium\template\view\adapter\File::render