summaryrefslogtreecommitdiff
path: root/src/View.php
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-01-02 20:42:01 +0100
committerDaniel Weipert <git@mail.dweipert.de>2024-01-05 12:33:59 +0100
commitb21316248572cb27ed1f504529ad6680a473022e (patch)
treef8a2f81258cae3b1d2429fb7df5a3287954b683a /src/View.php
parentf621d95f89ded05a2e916c5ee363bfe75ea37482 (diff)
gemini
Diffstat (limited to 'src/View.php')
-rw-r--r--src/View.php12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/View.php b/src/View.php
index 7862b12..1c29a67 100644
--- a/src/View.php
+++ b/src/View.php
@@ -9,11 +9,14 @@ use Twig\TwigFilter;
class View
{
- private static Environment $twig;
+ public static Environment $twig;
public static function init(): void
{
- $loader = new FilesystemLoader(dirname(__DIR__) . '/views');
+ $loader = new FilesystemLoader(
+ dirname(__DIR__) . '/views/' .
+ (isset($_ENV['GEMINI']) ? 'gemini' : 'http')
+ );
self::$twig = new Environment($loader, [
'debug' => $_ENV['APP_ENV'] === 'development',
]);
@@ -24,8 +27,11 @@ class View
self::$twig->addFilter(new TwigFilter('buildTime', function ($buildTime) {
return @sprintf('%02d:%02d:%02d', $buildTime / 3600, ($buildTime / 60) % 60, $buildTime % 60);
}));
+ }
- self::$twig->addGlobal('session', $_SESSION);
+ public static function addGlobal(string $name, mixed $value): void
+ {
+ self::$twig->addGlobal($name, $value);
}
/**