2 /** @package verysimple::Phreeze */
3 require_once("IRenderEngine.php");
4 require_once('savant/Savant3.php');
7 * Implementation of IRenderEngine that uses Savant as the template language
9 * @package verysimple::Phreeze
10 * @author VerySimple Inc.
11 * @copyright 1997-2010 VerySimple, Inc.
12 * @license http://www.gnu.org/licenses/lgpl.html LGPL
15 class SavantRenderEngine
implements IRenderEngine
17 static $TEMPLATE_EXTENSION = ".tpl.php";
24 * @param string $templatePath
25 * @param string $compilePath
26 * (not used for this render engine)
28 function __construct($templatePath = '', $compilePath = '')
30 $this->savant
= new Savant3(array (
35 if (substr($templatePath, - 1) != '/' && substr($templatePath, - 1) != '\\') {
40 $this->savant
->setPath('template', $templatePath);
47 public function assign($key, $value)
49 $this->savant
->$key = $value;
55 public function display($template)
57 // strip off .tpl from the end for backwards compatibility with older apps
58 if (substr($template, - 4) == '.tpl') {
59 $template = substr($template, 0, - 4);
62 // these two are special templates used by the Phreeze controller and dispatcher
63 if ($template == "_redirect") {
64 header("Location: " . $this->savant
->url
);
66 } elseif ($template == "_error") {
67 $this->savant
->display('_error' . self
::$TEMPLATE_EXTENSION);
69 $this->savant
->display($template . self
::$TEMPLATE_EXTENSION);
74 * Returns the specified model value
76 public function get($key)
78 return $this->savant
->$key;
84 public function fetch($template)
86 return $this->savant
->fetch($template . self
::$TEMPLATE_EXTENSION);
91 * @see IRenderEngine::clear()
95 if (array_key_exists($key, $this->savant
)) {
96 unset($this->savant
[$key]);
102 * @see IRenderEngine::clearAll()
106 throw new Exception('clearAll not implemented for SavantRenderEngine');
111 * @see IRenderEngine::getAll()
115 return get_object_vars($this->savant
);