diff options
Diffstat (limited to 'www/www-header.php')
| -rw-r--r-- | www/www-header.php | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/www/www-header.php b/www/www-header.php index 60adacf..2ec8c2f 100644 --- a/www/www-header.php +++ b/www/www-header.php @@ -12,6 +12,14 @@ $GLOBALS['twig'] = new \Twig_Environment( ); $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) { |
