You are here

public function Twig_Template::render in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/twig/twig/lib/Twig/Template.php \Twig_Template::render()

Renders the template with the given context and returns it as string.

Parameters

array $context An array of parameters to pass to the template:

Return value

string The rendered template

Overrides Twig_TemplateInterface::render

File

vendor/twig/twig/lib/Twig/Template.php, line 361

Class

Twig_Template
Default base class for compiled templates.

Code

public function render(array $context) {
  $level = ob_get_level();
  ob_start();
  try {
    $this
      ->display($context);
  } catch (Exception $e) {
    while (ob_get_level() > $level) {
      ob_end_clean();
    }
    throw $e;
  }
  return ob_get_clean();
}