function twig_include

Renders a template.

Parameters

string template The template to render:

array variables The variables to pass to the template:

Boolean with_context Whether to pass the current context variables or not:

Boolean ignore_missing Whether to ignore missing templates or not:

Boolean 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 drupal/core/vendor/twig/twig/lib/Twig/Extension/Core.php
Returns a list of global functions to add to the existing list.

File

drupal/core/vendor/twig/twig/lib/Twig/Extension/Core.php, line 1273

Code

function twig_include(Twig_Environment $env, $context, $template, $variables = array(), $withContext = true, $ignoreMissing = false, $sandboxed = false) {
  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)
      ->display($variables);
  } catch (Twig_Error_Loader $e) {
    if (!$ignoreMissing) {
      throw $e;
    }
  }
  if ($isSandboxed && !$alreadySandboxed) {
    $sandbox
      ->disableSandbox();
  }
}