4 const DIR = 'templates';
7 protected $templatePath;
9 public static function html($path, array $data=array())
11 $template = new Template($path);
12 return $template->render($data);
15 public function __construct($template)
17 $this->template = $template;
18 $this->templatePath = __DIR__ . '/../' . static::DIR . '/' . $this->template . '.phtml';
20 if (!is_readable($this->templatePath))
21 throw new Exception("Template {$this->template} not found");
24 public function render(array $data=array())
26 foreach ($data as $key => $value)
29 ob_start(); // Output Buffer einschalten
30 include($this->templatePath);
31 $renderedText = ob_get_contents();
32 ob_end_clean(); // Output Buffer beenden