X-Git-Url: https://git.cweiske.de/phinde.git/blobdiff_plain/226508cd8d3e8c147ad314a0de483e08be71c254..cd02bac646f42a0cb402ff2dc8240aa01f1f0fb8:/www/www-header.php 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) {