render() public method

Parse the incoming template
public render ( string $tpl, array $vars = [] ) : string
$tpl string Source template content
$vars array List of variables passed to template engine
return string Processed template
Example #1
0
 public function testRenderConstructorInjection()
 {
     $processor = new Processor(array(
         'cache' => dirname(__FILE__) . '/templates/',
     ));
     $tpl = file_get_contents($this->path . 'tpl1.twig');
     $rendered = $processor->render($tpl, array(
         'a_variable' => 'Aha!',
         'navigation' => array(
             array(
                 'href'      => 'link1',
                 'caption'   => 'caption1'
             ),
             array(
                 'href'      => 'link1',
                 'caption'   => 'caption1'
             )
         )
     ));
     
     $static = file_get_contents(dirname(__FILE__) . '/templates/tpl1.html');
     $this->assertSame(trim($static), trim($rendered));
 }