simplified some code

This commit is contained in:
Fabien Potencier
2019-03-11 16:43:04 +01:00
parent 2861b40965
commit d46e6d4a39
2 changed files with 3 additions and 18 deletions
+1 -3
View File
@@ -454,12 +454,10 @@ class Environment
$this->setLoader($loader); $this->setLoader($loader);
try { try {
$template = $this->loadTemplate($name); return $this->loadTemplate($name);
} finally { } finally {
$this->setLoader($current); $this->setLoader($current);
} }
return $template;
} }
/** /**
+2 -15
View File
@@ -1393,30 +1393,17 @@ function twig_include(Environment $env, $context, $template, $variables = [], $w
} }
} }
$result = '';
try { try {
$result = $env->resolveTemplate($template)->render($variables); return $env->resolveTemplate($template)->render($variables);
} catch (LoaderError $e) { } catch (LoaderError $e) {
if (!$ignoreMissing) { if (!$ignoreMissing) {
if ($isSandboxed && !$alreadySandboxed) {
$sandbox->disableSandbox();
}
throw $e; throw $e;
} }
} catch (\Throwable $e) { } finally {
if ($isSandboxed && !$alreadySandboxed) { if ($isSandboxed && !$alreadySandboxed) {
$sandbox->disableSandbox(); $sandbox->disableSandbox();
} }
throw $e;
} }
if ($isSandboxed && !$alreadySandboxed) {
$sandbox->disableSandbox();
}
return $result;
} }
/** /**