Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Becker <halfdan@xnorfz.de>2013-04-07 02:44:39 +0400
committerFabian Becker <halfdan@xnorfz.de>2013-04-07 02:44:39 +0400
commit7eb3401e64c12259b48d9da2ded908d4b7a56d14 (patch)
tree6b126742f9a13724eadd5e335c9c8cff7f4acf66 /core/Twig.php
parent91ce0bb684a742dd896ff8299e94c09617daa309 (diff)
New truncate filter (port of smarty feature)
Diffstat (limited to 'core/Twig.php')
-rw-r--r--core/Twig.php9
1 files changed, 9 insertions, 0 deletions
diff --git a/core/Twig.php b/core/Twig.php
index 120e788ce2..016ff053de 100644
--- a/core/Twig.php
+++ b/core/Twig.php
@@ -179,6 +179,15 @@ class Piwik_Twig
return Piwik::getPrettyMoney($amount, $idSite);
});
$this->twig->addFilter($moneyFilter);
+
+ $truncateFilter = new Twig_SimpleFilter('truncate', function($string, $size) {
+ if(strlen($string) < $size) {
+ return $string;
+ } else {
+ return array_shift(str_split($string, $size)) . "...";
+ }
+ });
+ $this->twig->addFilter($truncateFilter);
}
private function addPluginNamespaces(Twig_Loader_Filesystem $loader)