<?php /* * Copyright (c) 2022 Micha Espey <tracer@24unix.net> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace App\Service; /* * As I'm not allowed to use 3rd party code like Twig or Smarty I ended up * using PHP as a templating engine. */ class Template { /* * Just store the information about the template base dir. */ public function __construct(private readonly string $templateDir) { // empty body } /* * Add variables to template and throw it out */ public function render(string $templateName, array $vars = []): void { foreach ($vars as $name => $value) { $$name = $value; } include $this->templateDir . $templateName; exit(0); } }