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:
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 01282ef35d..69a6501d90 100644
--- a/core/Twig.php
+++ b/core/Twig.php
@@ -65,6 +65,7 @@ class Twig
$this->addFilter_money();
$this->addFilter_truncate();
$this->addFilter_notificiation();
+ $this->addFilter_percentage();
$this->twig->addFilter(new Twig_SimpleFilter('implode', 'implode'));
$this->twig->addFilter(new Twig_SimpleFilter('ucwords', 'ucwords'));
@@ -187,6 +188,14 @@ class Twig
$this->twig->addFilter($notificationFunction);
}
+ protected function addFilter_percentage()
+ {
+ $percentage = new Twig_SimpleFilter('percentage', function ($string, $totalValue, $precision = 1) {
+ return Piwik::getPercentageSafe($string, $totalValue, $precision) . '%';
+ });
+ $this->twig->addFilter($percentage);
+ }
+
protected function addFilter_truncate()
{
$truncateFilter = new Twig_SimpleFilter('truncate', function ($string, $size) {