class tpl { /* jefrey.sobreira@gmail.com */ var $keys = array(),$template; function template($tpl) { $this->template = $tpl; } function set($key, $value) { $this->keys[$key] = $value; } function show() { ob_start(); header("Content-type: text/html; charset=UTF-8"); $conteudo = file_get_contents('tpl/'.$this->template.'.tpl'); // includes $incs = array(); preg_match_all("/\{inc\(([^)]*)\)\}/", $conteudo, $incs); foreach($incs[1] as $inc) { $conteudo = str_replace('{inc('.$inc.')}', file_get_contents('tpl/'.$inc.'.tpl'), $conteudo); } foreach($this->keys as $key=>$value) { $conteudo = str_replace("{".$key."}", $value, $conteudo); } echo $conteudo; } }