Преглед изворни кода

Only load Twig_Extension_Debug when Twig's debug mode is enabled

Daniel Rudolf пре 8 година
родитељ
комит
05c8d95b3f
1 измењених фајлова са 7 додато и 2 уклоњено
  1. 7 2
      lib/Pico.php

+ 7 - 2
lib/Pico.php

@@ -1657,11 +1657,16 @@ class Pico
     public function getTwig()
     public function getTwig()
     {
     {
         if ($this->twig === null) {
         if ($this->twig === null) {
+            $twigConfig = $this->getConfig('twig_config');
+
             $twigLoader = new Twig_Loader_Filesystem($this->getThemesDir() . $this->getConfig('theme'));
             $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));
             $this->twig->addExtension(new PicoTwigExtension($this));
 
 
+            if (!empty($twigConfig['debug'])) {
+                $this->twig->addExtension(new Twig_Extension_Debug());
+            }
+
             // register content filter
             // register content filter
             // we pass the $pages array by reference to prevent multiple parser runs for the same page
             // 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
             // this is the reason why we can't register this filter as part of PicoTwigExtension