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.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/modules/templates/helper.go b/modules/templates/helper.go
index 03ec80f99c..e4107dfa9a 100644
--- a/modules/templates/helper.go
+++ b/modules/templates/helper.go
@@ -16,6 +16,7 @@ import (
"mime"
"net/url"
"path/filepath"
+ "reflect"
"regexp"
"runtime"
"strings"
@@ -310,6 +311,26 @@ func NewFuncMap() []template.FuncMap {
"EventSourceUpdateTime": int(setting.UI.Notification.EventSourceUpdateTime / time.Millisecond),
}
},
+ "containGeneric": func(arr interface{}, v interface{}) bool {
+ arrV := reflect.ValueOf(arr)
+ if arrV.Kind() == reflect.String && reflect.ValueOf(v).Kind() == reflect.String {
+ return strings.Contains(arr.(string), v.(string))
+ }
+
+ if arrV.Kind() == reflect.Slice {
+ for i := 0; i < arrV.Len(); i++ {
+ iV := arrV.Index(i)
+ if !iV.CanInterface() {
+ continue
+ }
+ if iV.Interface() == v {
+ return true
+ }
+ }
+ }
+
+ return false
+ },
"contain": func(s []int64, id int64) bool {
for i := 0; i < len(s); i++ {
if s[i] == id {