Whoops\Util\TemplateHelper::render PHP Method

render() public method

Given a template path, render it within its own scope. This method also accepts an array of additional variables to be passed to the template.
public render ( string $template, array $additionalVariables = null )
$template string
$additionalVariables array
    public function render($template, array $additionalVariables = null)
    {
        $variables = $this->getVariables();
        // Pass the helper to the template:
        $variables["tpl"] = $this;
        if ($additionalVariables !== null) {
            $variables = array_replace($variables, $additionalVariables);
        }
        call_user_func(function () {
            extract(func_get_arg(1));
            require func_get_arg(0);
        }, $template, $variables);
    }

Usage Example

 /**
  * @covers Whoops\Util\TemplateHelper::render
  */
 public function testRender()
 {
     $template = __DIR__ . "/../../fixtures/template.php";
     ob_start();
     $this->helper->render($template, array("name" => "B<o>b"));
     $output = ob_get_clean();
     $this->assertEquals($output, "hello-world\nMy name is B&lt;o&gt;b");
 }
All Usage Examples Of Whoops\Util\TemplateHelper::render