You are here

function twig_include in Translation template extractor 6.3

Same name and namespace in other branches
  1. 7.3 vendor/Twig/Extension/Core.php \twig_include()

Renders a template.

Parameters

string|array $template The template to render or an array of templates to try consecutively:

array $variables The variables to pass to the template:

bool $with_context Whether to pass the current context variables or not:

bool $ignore_missing Whether to ignore missing templates or not:

bool $sandboxed Whether to sandbox the template or not:

Return value

string The rendered template

1 string reference to 'twig_include'
Twig_Extension_Core::getFunctions in vendor/Twig/Extension/Core.php
Returns a list of global functions to add to the existing list.

File

vendor/Twig/Extension/Core.php, line 1412

Code

function twig_include(Twig_Environment $env, $context, $template, $variables = array(), $withContext = true, $ignoreMissing = false, $sandboxed = false) {
  $alreadySandboxed = false;
  $sandbox = null;
  if ($withContext) {
    $variables = array_merge($context, $variables);
  }
  if ($isSandboxed = $sandboxed && $env
    ->hasExtension('sandbox')) {
    $sandbox = $env
      ->getExtension('sandbox');
    if (!($alreadySandboxed = $sandbox
      ->isSandboxed())) {
      $sandbox
        ->enableSandbox();
    }
  }
  try {
    return $env
      ->resolveTemplate($template)
      ->render($variables);
  } catch (Twig_Error_Loader $e) {
    if (!$ignoreMissing) {
      throw $e;
    }
  }
  if ($isSandboxed && !$alreadySandboxed) {
    $sandbox
      ->disableSandbox();
  }
}