added copyright
This commit is contained in:
parent
e9fd8e153d
commit
8a7a4a2253
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue