function template_fill($template_name, $vars = array()) { $loader = new Twig_Loader_Filesystem('templates'); $twig = new Twig_Environment($loader, array('cache' => false, 'autoescape' => true, 'autoreload' => true)); $class = new ReflectionClass($twig); $methods = $class->getMethods(); $twig->addGlobal('get', $_GET); $twig->addGlobal('post', $_POST); $twig->addGlobal('request', $_REQUEST); $twig->addGlobal('session', $_SESSION); $callback_values = process_callbacks(template_callbacks()); $vars = array_merge($callback_values, $vars); $template = $twig->loadTemplate($template_name . ".html"); return $template->render($vars); }
public function set_template_callbacks() { template_callbacks(array($this, 'debug_messages'), 'debug_messages'); }