diff options
Diffstat (limited to 'src/index.php')
| -rw-r--r-- | src/index.php | 9 | 
1 files changed, 6 insertions, 3 deletions
| diff --git a/src/index.php b/src/index.php index 5350680..8036a19 100644 --- a/src/index.php +++ b/src/index.php @@ -27,6 +27,7 @@ if (($_SERVER["HTTP_USER_AGENT"] ?? "") === "") {  }  define("REGISTRATION_ENABLED", isTrue(env("REGISTRATION_ENABLED") ?? "")); +define("DEBUG", isTrue(env("DEBUG") ?? ""));  const __ROOT__ = __DIR__; @@ -172,9 +173,11 @@ function render(string $page, array $context = [], array $functions = []): void      $loader = new FilesystemLoader([          $templateDir . "/" . $currentTemplate,      ]); -    $twig = new Environment($loader, [ -        // TODO Enable caching -    ]); +    $twigEnvConfig = []; +    if (!DEBUG) { +        $twigEnvConfig["cache"] = sys_get_temp_dir() . DIRECTORY_SEPARATOR . "mybb-template-cache"; +    } +    $twig = new Environment($loader, $twigEnvConfig);      $twig->addFunction(new TwigFunction("__", __(...), [ "is_safe" => ["html"] ]));      $twig->addFunction(new TwigFunction("___", ___(...), [ "is_safe" => ["html"] ])); |