summaryrefslogtreecommitdiffstats
path: root/modules/templates
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-07-25 00:03:58 +0800
committerGitHub <noreply@github.com>2021-07-24 18:03:58 +0200
commit9f31f3aa8ac4f6bfc8390c9ae63b2a387b414c88 (patch)
tree6f27dc68a35d1f9d806c632e36f0edc8543184ea /modules/templates
parente0f9635c0691cb67f0fcbb758cabba801d9fc51b (diff)
downloadgitea-9f31f3aa8ac4f6bfc8390c9ae63b2a387b414c88.tar.gz
gitea-9f31f3aa8ac4f6bfc8390c9ae63b2a387b414c88.zip
Add an abstract json layout to make it's easier to change json library (#16528)
* Add an abstract json layout to make it's easier to change json library * Fix import * Fix import sequence * Fix blank lines * Fix blank lines
Diffstat (limited to 'modules/templates')
-rw-r--r--modules/templates/helper.go7
1 files changed, 2 insertions, 5 deletions
diff --git a/modules/templates/helper.go b/modules/templates/helper.go
index d4913f7c41..1e8f00b669 100644
--- a/modules/templates/helper.go
+++ b/modules/templates/helper.go
@@ -8,7 +8,6 @@ package templates
import (
"bytes"
"container/list"
- "encoding/json"
"errors"
"fmt"
"html"
@@ -28,6 +27,7 @@ import (
"code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/emoji"
"code.gitea.io/gitea/modules/git"
+ "code.gitea.io/gitea/modules/json"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/markup"
"code.gitea.io/gitea/modules/repository"
@@ -38,7 +38,6 @@ import (
"code.gitea.io/gitea/services/gitdiff"
"github.com/editorconfig/editorconfig-core-go/v2"
- jsoniter "github.com/json-iterator/go"
)
// Used from static.go && dynamic.go
@@ -46,7 +45,6 @@ var mailSubjectSplit = regexp.MustCompile(`(?m)^-{3,}[\s]*$`)
// NewFuncMap returns functions for injecting to templates
func NewFuncMap() []template.FuncMap {
- jsonED := jsoniter.ConfigCompatibleWithStandardLibrary
return []template.FuncMap{map[string]interface{}{
"GoVer": func() string {
return strings.Title(runtime.Version())
@@ -221,7 +219,7 @@ func NewFuncMap() []template.FuncMap {
return fmt.Sprintf("%f", float64(adds)/(float64(adds)+float64(dels))*100)
},
"Json": func(in interface{}) string {
- out, err := jsonED.Marshal(in)
+ out, err := json.Marshal(in)
if err != nil {
return ""
}
@@ -847,7 +845,6 @@ func ActionContent2Commits(act Actioner) *repository.PushCommits {
return push
}
- json := jsoniter.ConfigCompatibleWithStandardLibrary
if err := json.Unmarshal([]byte(act.GetContent()), push); err != nil {
log.Error("json.Unmarshal:\n%s\nERROR: %v", act.GetContent(), err)
}