added copyright

This commit is contained in:
tracer 2022-10-23 12:26:30 +02:00
parent e9fd8e153d
commit 8a7a4a2253
1 changed files with 22 additions and 4 deletions

View File

@ -1,18 +1,36 @@
<?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;
use Exception;
/*
* 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
}
public function render(string $templateName): void
/*
* 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;
}
}