Dai un occhio a questo sfruttatissimo e vecchio
modo.
Il metodo che usi tu è ancora + vecchio
implode("",file($template)
c'è file_get_contents
questo accenno mi sembra un attimo
+ performante e molto + pulito 
Codice PHP:
class Template{
function render(/* $file, $model = Array() */) {
if (!is_string(func_get_arg(0))) {
throw new Exception("Wrong argument type. Expected string as first parameter");
}
if (func_num_args() > 1) {
extract(func_get_arg(1));
}
$__template_filename__ = func_get_arg(0);
if (!is_file($__template_filename__)) {
throw new Exception("Failed opening '".func_get_arg(0)."' for inclusion. (include_path=".ini_get('include_path').")");
}
ob_start();
include($__template_filename__);
return ob_get_clean();
}
}
$var_array = array("pippo" => "blue");
$t= new Template();
echo $t->render('templateTpl.php',$var_array);
il template
Codice PHP:
<?php echo $pippo;?></p>