Código PHP:
<?php
//incluimos la clase
include('class/clase_plantilla.php');
include('lolq.php');
//iniciamos la clase
$php=new TemplateClass();
//indicamos la plantilla sin extencion solo el nombre
echo $php->Template('VnzCloud/index');
?>
Código PHP:
<?php
//esta es la clase
class TemplateClass{
//Declaraciones
private $_dir = 'templates/'; //carpeta de los archivos .tpl (los templates)
private $_file_ext = '.php'; //formato de los templates, (default = .tpl)
private $_vars = array(); //variables a transformar
private $_delimiters = array('{', '}'); //limitadores para saber donde tiene que buscar (ejemplo = {ejemplo})
public function Assign($name, $value){
if(!array_key_exists($name, $this->_vars))
$this->_vars[$name] = $value;
}
public function GetAssign($name){
return $this->_vars{$name};
}
public function Template($file){
if( $output = @file_get_contents($this->_dir.$file.$this->_file_ext)){
foreach($this->_vars as $name => $value){
$output = str_replace($this->_delimiters[0].$name.$this->_delimiters[1], $value, $output);
}
return $output;
}
else
die("La plantilla no existe.");
}
}
?>