1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Add reactions to issues/PR and comments (#2856)

This commit is contained in:
Lauris BH
2017-12-04 01:14:26 +02:00
committed by GitHub
parent e59adcde65
commit 5dc37b187c
24 changed files with 677 additions and 8 deletions

View File

@@ -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,
}}
}