Someone
public text v1 · immutable<?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;
}
}