Renders a template.
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:
string The rendered template
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();
}
}