commit
This commit is contained in:
28
src/App/functions.php
Normal file
28
src/App/functions.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Lädt ein Template-Partial.
|
||||
*
|
||||
* @param string $name Dateiname ohne .php
|
||||
* @param string $folder Unterordner in /public/partials/
|
||||
* @param array $data Daten, die im Template verfügbar sein sollen
|
||||
*/
|
||||
function tpl(string $name, string $folder = 'landing', array $data = []): void
|
||||
{
|
||||
$path = __DIR__ . '/../../public/partials/' . $folder . '/' . $name . '.php';
|
||||
if (file_exists($path)) {
|
||||
extract($data);
|
||||
require $path;
|
||||
} else {
|
||||
echo "<!-- Template not found: {$folder}/{$name} -->";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* HTML Escaping Helper.
|
||||
*/
|
||||
function e(?string $string): string
|
||||
{
|
||||
return htmlspecialchars($string ?? '', ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
Reference in New Issue
Block a user