rebuild to module
This commit is contained in:
@@ -13,6 +13,16 @@ function t(string $key, $default = '', array $vars = []): string
|
||||
return app()->i18n()->get($key, $default, $vars);
|
||||
}
|
||||
|
||||
function modules(): \App\ModuleManager
|
||||
{
|
||||
return app()->modules();
|
||||
}
|
||||
|
||||
function module_fn(string $module, string $name, mixed ...$args): mixed
|
||||
{
|
||||
return modules()->call($module, $name, ...$args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lädt ein Template-Partial.
|
||||
*
|
||||
@@ -56,6 +66,24 @@ function tpl(string $name, string $folder = 'landing', array $data = []): void
|
||||
require $path;
|
||||
}
|
||||
|
||||
function module_tpl(string $module, string $name, array $data = []): void
|
||||
{
|
||||
$base = __DIR__ . '/../../modules/' . $module . '/partials/';
|
||||
foreach ([$module, $name] as $value) {
|
||||
if (preg_match('/[^a-zA-Z0-9_\-]/', $value)) {
|
||||
echo "<!-- module_tpl(): invalid parameter -->";
|
||||
return;
|
||||
}
|
||||
}
|
||||
$path = $base . $name . '.php';
|
||||
if (file_exists($path)) {
|
||||
extract($data);
|
||||
require $path;
|
||||
} else {
|
||||
echo "<!-- module_tpl(): not found: {$module}/{$name} -->";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* HTML Escaping Helper.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user