You are here

public function Twig_Template::render in Translation template extractor 6.3

Same name and namespace in other branches
  1. 7.3 vendor/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/Template.php, line 259

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();
}