27 lines
623 B
PHP
27 lines
623 B
PHP
|
<?php
|
||
|
|
||
|
namespace Framework;
|
||
|
|
||
|
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);
|
||
|
require "views/{$tmpname}.view.php";
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
// $templ = Template::render('about', '['title' => 'About']');
|
||
|
|
||
|
?>
|