blob: 070c391484e3967f317ad353b8c395fa9c442991 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
<?php
namespace phinde;
require_once __DIR__ . '/../src/init.php';
\Twig_Autoloader::register();
$GLOBALS['twig'] = new \Twig_Environment(
new \Twig_Loader_Filesystem(__DIR__ . '/../data/templates'),
array(
//'cache' => '/path/to/compilation_cache',
'debug' => true
)
);
$GLOBALS['twig']->addExtension(new \Twig_Extension_Debug());
$twig->addFunction('ellipsis', new \Twig_Function_Function('\phinde\ellipsis'));
function ellipsis($text, $maxlength)
{
if (strlen($text) > $maxlength) {
$text = substr($text, 0, $maxlength - 1) . '…';
}
return $text;
}
function render($tplname, $vars = array(), $return = false)
{
if (!isset($vars['htmlhelper'])) {
//$vars['htmlhelper'] = new HtmlHelper();
}
$vars['apptitle'] = $GLOBALS['phinde']['apptitle'];
$vars['baseUrl'] = '/';
$template = $GLOBALS['twig']->loadTemplate($tplname . '.htm');
if ($return) {
return $template->render($vars);
} else {
echo $template->render($vars);
}
}
?>
|