sealandia-framework/framework/template.php

27 lines
633 B
PHP
Raw Normal View History

2024-08-13 09:06:11 +02:00
<?php
2024-08-15 16:10:53 +02:00
namespace sealandia\framework;
2024-08-13 09:06:11 +02:00
class Template{
/**
* Method to render the template file with additional data
*/
public function render($tmpname, $args){
/**
* Extracts variables from the associative array $args, making each key a variable in the current scope.
* EXTR_SKIP ensures that existing variables with the same name are not overwritten.
* Then Include the specified view file for rendering.
*/
extract($args, EXTR_SKIP);
2024-08-15 16:10:53 +02:00
require "views/{$tmpname}.view.php";
2024-08-13 09:06:11 +02:00
}
}
2024-08-15 08:54:44 +02:00
// $templ = Template::render('about', '['title' => 'About']');
2024-08-13 09:06:11 +02:00
?>