class Templates {
private $loader;
private $twig;
public function __construct() {
Twig_Autoloader::register();
$this->loader = new Twig_Loader_Filesystem($_SERVER['DOCUMENT_ROOT'].'/tpl');
$this->twig = new Twig_Environment($loader, array( 'cache' => false ));
}
private function ShowPage ($template_file, $variables){
$template = $this->twig->loadTemplate($template_file);
echo $template->render($variables);
}
function ShowMainPage (){
$this->ShowPage('index.tpl', array());
}
}
function __autoload($class_name) {
switch ($class_name){
case "Twig_Autoloader":
require_once '/Twig/Autoloader.php';
break;
default:
include ($_SERVER['DOCUMENT_ROOT'].'/classes/'.$class_name . '.class.php');
}
}
$page = new Templates();
$page->ShowMainPage();
но
Fatal error: Call to a member function getCacheKey() on a non-object in C:\xampp\htdocs\mypage\Twig\Environment.php on line 152