All pastes #813257 Raw Edit

Someone

public text v1 · immutable
·published 2007-12-12 11:59 UTC
rendered paste body
<?php
class Template {
	//With trailing slash
	public $TEMPLATE_DIR = 'templates/';
	public $TEMPLATE_EXT = '.php';
	
	function load($template, array $data) {
		$this->format_template($template);

		if(!file_exists($template)) {
			trigger_error("Template '$template' does not exist", E_USER_ERROR);
		}

		foreach($data as $name => $value) {
			$$name = $value;
		}
		include $template;
	}

	function format_template(&$template) {
		$template = $this->TEMPLATE_DIR . $template . $this->TEMPLATE_EXT;
	}
}