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
Beispiel #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);
 }
Beispiel #2
0
 public function testRenderingWithNoExtraction()
 {
     $backup = error_reporting();
     error_reporting(E_ALL);
     $file = new File(array('extract' => false));
     $path = $this->_path;
     $this->assertException('Undefined variable: foo', function () use($file, $path) {
         $file->render("{$path}/template1.html.php", array('foo' => 'bar'));
     });
     $content = $file->render("{$this->_path}/template2.html.php", array('foo' => 'bar'));
     $this->assertEqual('bar', $content);
     error_reporting($backup);
 }