_[$key] = $value; } /** * Sets templates name * * @param String $template Name of template */ public function setTemplate($template = 'default') { $this->template = $template; } /** * Load template and return result * * @return string Output of template */ public function loadTemplate() { $tpl = $this->template; $file = $this->path . DIRECTORY_SEPARATOR . $tpl . '.php'; if(file_exists($file)) { // Write output to buffer ob_start(); extract($this->_); // make vars available via name not array, forbidden vars: $tpl, $file, $output // Include template and save output to $output include($file); $output = ob_get_contents(); ob_end_clean(); return $output . PHP_EOL; } else { // Couldn't find template // TODO: Throw exception // TODO: test if deprecated (see: controller display()) ErrorHandler::$eh->addError("Could not load template: " . $tpl); } } } ?>