Added a way to include template args as string

This commit is contained in:
Niko 2022-02-11 13:46:27 +01:00
parent 5f98b94ff3
commit e9d69b7d0f
1 changed files with 10 additions and 0 deletions

View File

@ -12,6 +12,16 @@ function urlargs($from = 0) {
} }
function tpl($ns, $args=[]) { function tpl($ns, $args=[]) {
if (gettype($args) === 'string') {
$ps = explode('|', $args);
$args = [];
foreach ($ps as $p) {
$p = trim($p);
$k = trim(substr($p, 0, strpos($p, ':')));
$v = trim(substr($p, strpos($p, ':')+1));
$args[$k] = $v;
}
}
$ns = str_replace('.','/',$ns); $ns = str_replace('.','/',$ns);
$__tfile = "_templates/$ns.php"; $__tfile = "_templates/$ns.php";
if (file_exists($__tfile)) { if (file_exists($__tfile)) {