You are here

public function Twig_Template::displayBlock in Translation template extractor 6.3

Same name and namespace in other branches
  1. 7.3 vendor/Twig/Template.php \Twig_Template::displayBlock()

Displays a block.

This method is for internal use only and should never be called directly.

Parameters

string $name The block name to display:

array $context The context:

array $blocks The current set of blocks:

bool $useBlocks Whether to use the current set of blocks:

1 call to Twig_Template::displayBlock()
Twig_Template::renderBlock in vendor/Twig/Template.php
Renders a block.

File

vendor/Twig/Template.php, line 127

Class

Twig_Template
Default base class for compiled templates.

Code

public function displayBlock($name, array $context, array $blocks = array(), $useBlocks = true) {
  $name = (string) $name;
  if ($useBlocks && isset($blocks[$name])) {
    $template = $blocks[$name][0];
    $block = $blocks[$name][1];
  }
  elseif (isset($this->blocks[$name])) {
    $template = $this->blocks[$name][0];
    $block = $this->blocks[$name][1];
  }
  else {
    $template = null;
    $block = null;
  }
  if (null !== $template) {
    try {
      $template
        ->{$block}($context, $blocks);
    } catch (Twig_Error $e) {
      throw $e;
    } catch (Exception $e) {
      throw new Twig_Error_Runtime(sprintf('An exception has been thrown during the rendering of a template ("%s").', $e
        ->getMessage()), -1, $template
        ->getTemplateName(), $e);
    }
  }
  elseif (false !== ($parent = $this
    ->getParent($context))) {
    $parent
      ->displayBlock($name, $context, array_merge($this->blocks, $blocks), false);
  }
}