3 require_once __DIR__ . '/../src/init.php';
5 \Twig_Autoloader::register();
6 $GLOBALS['twig'] = new \Twig_Environment(
7 new \Twig_Loader_Filesystem(__DIR__ . '/../data/templates'),
9 //'cache' => '/path/to/compilation_cache',
13 $GLOBALS['twig']->addExtension(new \Twig_Extension_Debug());
15 $twig->addFunction('ellipsis', new \Twig_Function_Function('\phinde\ellipsis'));
16 function ellipsis($text, $maxlength)
18 if (strlen($text) > $maxlength) {
19 $text = substr($text, 0, $maxlength - 1) . '…';
24 function render($tplname, $vars = array(), $return = false)
26 if (!isset($vars['htmlhelper'])) {
27 //$vars['htmlhelper'] = new HtmlHelper();
29 $vars['apptitle'] = $GLOBALS['phinde']['apptitle'];
30 $vars['baseUrl'] = '/';
32 $template = $GLOBALS['twig']->loadTemplate($tplname . '.htm');
34 return $template->render($vars);
36 echo $template->render($vars);