Revisions

gist: 217503 Download_button fork
public
Public Clone URL: git://gist.github.com/217503.git
Embed All Files: show embed
Template.php #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
* Basic template system
* Usage:
* <code>
* $template = new Template(BASE_DIR.'/templates/my_template.tpl.php');
* echo $template->render(array('title'=>'My title');
* </code>
*/
 
class Template
{
/**
* Create the template object
* @param string $template_path
*/
function __constuct($template_path)
{
$this->template_path = $template_path;
}
 
/**
* Render template
* @param array $var_array
* @return string
*/
function render($var_array)
{
foreach($var_array as $key=>$value) {
$this->$key = $value;
}
ob_start();
include $this->template_path;
return ob_get_clean();
}
 
}