/ Published in: PHP
Please, feel free to suggest improvements
Expand |
Embed | Plain Text
<?php class Template { /* * Array containing the variables to be used inside the template */ /* * Absolute path to views directory */ protected $view_path; /* * Stores a variable to use inside a template * * @param string $name The name of the variable to use inside of the template * @param string $value The value of the variable */ public function set($name, $value = null) { foreach ($name as $key => $value) { $this->properties[$key] = $value; } } else { $this->properties[$name] = $value; } } /* * Renders the given template * * @param string $template The name of the template to render */ public function render($template) { $file = $this->view_path . $template . '.tpl'; foreach ($this->properties as $key => $value) { $$key = $value; } include($file); echo $content; } } ?>
You need to login to post a comment.
