/** * Set a new template file * */ public function setFile($file) { $fullpath = OOTemplate_Setting::generate_path($file); if (!file_exists($fullpath)) { throw new OOTemplate_Exception("template {$file}, not found in {$fullpath}\n"); } $this->_file = $file; $this->setContents(file_get_contents($fullpath)); return $this; }
public function render(OOTemplate_Context $context) { try { list(, $arg) = $this->_token->split(); if (strpos($arg, "'") === false && strpos($arg, '"') === false) { $o = new OOTemplate_Variable($arg); $file = $o->resolve($context); } else { $file = trim($arg, '\'" '); } $result = @file_get_contents(OOTemplate_Setting::generate_inc_path($file)); if ($result === false) { throw new OOTemplate_Exception(vsprintf('failed to open stream: %s, check OOTemplate_Setting::$dir_include', $file)); } } catch (OOTemplate_Exception $e) { OOTemplate_Debug::show($e->getMessage()); } return $result; }