aboutsummaryrefslogtreecommitdiff
path: root/lib/PhpTemplate.php
blob: 1f4b27c18f7752321abf7cdcbd510b8bb8b18583 (plain)
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
38
39
40
41
<?php

// Version 1.2

if(!function_exists('h'))
{
	function h($s)
	{
		return htmlspecialchars($s);
	}
}

class PhpTemplate
{
	private $data = array();

	public function __construct($file)
	{
		$this->file = $file;
	}

	public function set($___data = array())
	{
		$this->data = array_merge($this->data, $___data);
	}

	public function render($___data = array())
	{
		extract(array_merge($this->data, $___data));
		unset($___data);

		ob_start();
		require($this->file);
		return ob_get_clean();
	}
	
	public function __tostring()
	{
		return $this->render();
	}
}