Catch twig parser errors
This commit is contained in:
parent
701bf6c1ed
commit
4e16444d2f
@ -15,10 +15,14 @@ class TwigParser extends AbstractParser
|
|||||||
|
|
||||||
public function parseView(string $content): string
|
public function parseView(string $content): string
|
||||||
{
|
{
|
||||||
$arrayLoader = new ArrayLoader([
|
try {
|
||||||
'index' => $content,
|
$arrayLoader = new ArrayLoader([
|
||||||
]);
|
'index' => $content,
|
||||||
$twig = new Environment($arrayLoader);
|
]);
|
||||||
return $twig->render('index');
|
$twig = new Environment($arrayLoader);
|
||||||
|
return $twig->render('index');
|
||||||
|
}catch (\Exception $exception) {
|
||||||
|
return sprintf('<pre><code class="hljs">%s</code></pre>', htmlspecialchars($exception->getMessage()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user