summaryrefslogtreecommitdiff
path: root/src/Template.php
blob: b4360b80166bfee75022ebf760831447c4e81ef3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php

namespace Elements;

use Twig\Environment;
use Twig\Loader\FilesystemLoader;

class Template
{
  public static ?Environment $twig = null;

  public static function init(): void
  {
    $loader = new FilesystemLoader(dirname(__DIR__) . '/templates');
    self::$twig = new Environment($loader);
  }

  public static function render(string $name, array $context = []): string
  {
    return self::$twig->render($name, $context);
  }
}