summaryrefslogtreecommitdiffstats
path: root/modules/templates
diff options
context:
space:
mode:
authorLauris BH <lauris@nix.lv>2017-12-04 01:14:26 +0200
committerGitHub <noreply@github.com>2017-12-04 01:14:26 +0200
commit5dc37b187c8b839a15ff73758799f218ddeb3bc9 (patch)
treeb63e5ca72c7b9e72c79408ace82dfcba992b5793 /modules/templates
parente59adcde655aac0e8afd3249407c9a0a2b1b1d6b (diff)
downloadgitea-5dc37b187c8b839a15ff73758799f218ddeb3bc9.tar.gz
gitea-5dc37b187c8b839a15ff73758799f218ddeb3bc9.zip
Add reactions to issues/PR and comments (#2856)
Diffstat (limited to 'modules/templates')
-rw-r--r--modules/templates/helper.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/modules/templates/helper.go b/modules/templates/helper.go
index 42e465aeaa..c8b872d9f5 100644
--- a/modules/templates/helper.go
+++ b/modules/templates/helper.go
@@ -8,6 +8,7 @@ import (
"bytes"
"container/list"
"encoding/json"
+ "errors"
"fmt"
"html/template"
"mime"
@@ -162,6 +163,21 @@ func NewFuncMap() []template.FuncMap {
return setting.DisableGitHooks
},
"TrN": TrN,
+ "Dict": func(values ...interface{}) (map[string]interface{}, error) {
+ if len(values)%2 != 0 {
+ return nil, errors.New("invalid dict call")
+ }
+ dict := make(map[string]interface{}, len(values)/2)
+ for i := 0; i < len(values); i += 2 {
+ key, ok := values[i].(string)
+ if !ok {
+ return nil, errors.New("dict keys must be strings")
+ }
+ dict[key] = values[i+1]
+ }
+ return dict, nil
+ },
+ "Printf": fmt.Sprintf,
}}
}