From 05c8d95b3f9bae41819fe89295b7b3ec12b47891 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Tue, 20 Jun 2017 23:34:07 +0200 Subject: [PATCH] Only load Twig_Extension_Debug when Twig's debug mode is enabled --- lib/Pico.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/Pico.php b/lib/Pico.php index bffd9fe..8f989d7 100644 --- a/lib/Pico.php +++ b/lib/Pico.php @@ -1657,11 +1657,16 @@ class Pico public function getTwig() { if ($this->twig === null) { + $twigConfig = $this->getConfig('twig_config'); + $twigLoader = new Twig_Loader_Filesystem($this->getThemesDir() . $this->getConfig('theme')); - $this->twig = new Twig_Environment($twigLoader, $this->getConfig('twig_config')); - $this->twig->addExtension(new Twig_Extension_Debug()); + $this->twig = new Twig_Environment($twigLoader, $twigConfig); $this->twig->addExtension(new PicoTwigExtension($this)); + if (!empty($twigConfig['debug'])) { + $this->twig->addExtension(new Twig_Extension_Debug()); + } + // register content filter // we pass the $pages array by reference to prevent multiple parser runs for the same page // this is the reason why we can't register this filter as part of PicoTwigExtension