forked from forgejo/forgejo
Add reactions to issues/PR and comments (#2856)
This commit is contained in:
parent
e59adcde65
commit
5dc37b187c
24 changed files with 677 additions and 8 deletions
|
@ -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,
|
||||
}}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue