diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2024-01-09 16:16:56 +0100 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2024-01-09 16:16:56 +0100 |
commit | 6301f63bd348109b8693a922f02e16d49205a8fd (patch) | |
tree | eda5b3bf547340c62540f64ad84c7f079803f497 /src | |
parent | e4351601a7ced91bf5a2c516a38db714d43e6ecf (diff) |
enable indentation for gemini templates
Diffstat (limited to 'src')
-rw-r--r-- | src/View.php | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/View.php b/src/View.php index 1c29a67..10ce9db 100644 --- a/src/View.php +++ b/src/View.php @@ -40,6 +40,18 @@ class View */ public static function render(string $name, array $context = []): string { - return self::$twig->render($name, $context); + if (isset($_ENV['GEMINI'])) { + $string = self::$twig->render($name, $context); + $lines = explode(PHP_EOL, $string); + $output = ''; + + foreach ($lines as $line) { + $output .= ltrim($line, ' \t') . "\r\n"; + } + + return $output; + } else { + return self::$twig->render($name, $context); + } } } |