summaryrefslogtreecommitdiff
path: root/src/index.php
diff options
context:
space:
mode:
authorJonas Kohl2024-12-22 13:13:25 +0100
committerJonas Kohl2024-12-22 13:13:25 +0100
commit11fed2c8ce3dd38fe686e7b27db738f64373fe3d (patch)
tree070024ba00c0929daaab306538972e4268975a6f /src/index.php
parent08e4128ddce9dcffe0a4224ae57ad664609935b2 (diff)
Add template cachingHEADv0.7.1main
Diffstat (limited to 'src/index.php')
-rw-r--r--src/index.php9
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"] ]));