Location: PHPKode > projects > Dev's CMS > devscms/includes/class.templates.php
<?php

class template
{
	private $_vars = array();
	private $_file;
	private $_templatesPath;

	function __construct($file)
	{
		$this->_templatesPath = config::getConfig()->template->path;
		$this->_file = $this->_templatesPath . "{$file}.tpl";
	}
	
	public function get($name, $default)
	{
		return isset($this->_vars[$name]) ? $this->_vars[$name] : $default;
	}
	
	public function set($name, $value)
	{
		$this->_vars[$name] = is_object($value) ? $value->fetch() : $value;
	}

	public function fetch()
	{
		extract($this->_vars);          // Extract the vars to local namespace
		ob_start();                    // Start output buffering
		include($this->_file);          // Include the file
		$contents = ob_get_contents(); // Get the contents of the buffer
		ob_end_clean();                // End buffering and discard
		return $contents;              // Return the contents
	}

	public function render()
	{
		echo $this->fetch();
	}
}
Return current item: Dev's CMS