summaryrefslogtreecommitdiffstats
path: root/modules/templates/helper.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/templates/helper.go')
-rw-r--r--modules/templates/helper.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/modules/templates/helper.go b/modules/templates/helper.go
index 6d964e88a5..3176684d82 100644
--- a/modules/templates/helper.go
+++ b/modules/templates/helper.go
@@ -223,6 +223,13 @@ func NewFuncMap() []template.FuncMap {
}
return dict, nil
},
+ "percentage": func(n int, values ...int) float32 {
+ var sum = 0
+ for i := 0; i < len(values); i++ {
+ sum += values[i]
+ }
+ return float32(n) * 100 / float32(sum)
+ },
}}
}