aboutsummaryrefslogtreecommitdiffstats
path: root/modules/templates
diff options
context:
space:
mode:
authorsilverwind <me@silverwind.io>2023-07-04 20:36:08 +0200
committerGitHub <noreply@github.com>2023-07-04 18:36:08 +0000
commit88f835192d1a554d233b0ec4daa33276b7eb2910 (patch)
tree438140c295791e64a3b78dcfeae57701bcf296c3 /modules/templates
parent00dbba7f4266032a2b91b760e7c611950ffad096 (diff)
downloadgitea-88f835192d1a554d233b0ec4daa33276b7eb2910.tar.gz
gitea-88f835192d1a554d233b0ec4daa33276b7eb2910.zip
Replace `interface{}` with `any` (#25686)
Result of running `perl -p -i -e 's#interface\{\}#any#g' **/*` and `make fmt`. Basically the same [as golang did](https://github.com/golang/go/commit/2580d0e08d5e9f979b943758d3c49877fb2324cb).
Diffstat (limited to 'modules/templates')
-rw-r--r--modules/templates/helper.go6
-rw-r--r--modules/templates/htmlrenderer.go2
-rw-r--r--modules/templates/scopedtmpl/scopedtmpl.go2
-rw-r--r--modules/templates/util_avatar.go8
-rw-r--r--modules/templates/util_misc.go2
5 files changed, 10 insertions, 10 deletions
diff --git a/modules/templates/helper.go b/modules/templates/helper.go
index 2f2ef44049..2b918f42c0 100644
--- a/modules/templates/helper.go
+++ b/modules/templates/helper.go
@@ -27,7 +27,7 @@ import (
// NewFuncMap returns functions for injecting to templates
func NewFuncMap() template.FuncMap {
- return map[string]interface{}{
+ return map[string]any{
"DumpVar": dumpVar,
// -----------------------------------------------------------------
@@ -142,8 +142,8 @@ func NewFuncMap() template.FuncMap {
"DefaultTheme": func() string {
return setting.UI.DefaultTheme
},
- "NotificationSettings": func() map[string]interface{} {
- return map[string]interface{}{
+ "NotificationSettings": func() map[string]any {
+ return map[string]any{
"MinTimeout": int(setting.UI.Notification.MinTimeout / time.Millisecond),
"TimeoutStep": int(setting.UI.Notification.TimeoutStep / time.Millisecond),
"MaxTimeout": int(setting.UI.Notification.MaxTimeout / time.Millisecond),
diff --git a/modules/templates/htmlrenderer.go b/modules/templates/htmlrenderer.go
index e0cbc49ff4..d470435b63 100644
--- a/modules/templates/htmlrenderer.go
+++ b/modules/templates/htmlrenderer.go
@@ -39,7 +39,7 @@ var (
var ErrTemplateNotInitialized = errors.New("template system is not initialized, check your log for errors")
-func (h *HTMLRender) HTML(w io.Writer, status int, name string, data interface{}) error {
+func (h *HTMLRender) HTML(w io.Writer, status int, name string, data any) error {
if respWriter, ok := w.(http.ResponseWriter); ok {
if respWriter.Header().Get("Content-Type") == "" {
respWriter.Header().Set("Content-Type", "text/html; charset=utf-8")
diff --git a/modules/templates/scopedtmpl/scopedtmpl.go b/modules/templates/scopedtmpl/scopedtmpl.go
index a8b67ad0f9..2722ba97a2 100644
--- a/modules/templates/scopedtmpl/scopedtmpl.go
+++ b/modules/templates/scopedtmpl/scopedtmpl.go
@@ -15,7 +15,7 @@ import (
)
type TemplateExecutor interface {
- Execute(wr io.Writer, data interface{}) error
+ Execute(wr io.Writer, data any) error
}
type ScopedTemplate struct {
diff --git a/modules/templates/util_avatar.go b/modules/templates/util_avatar.go
index 3badc97cb9..9f8f8f87a9 100644
--- a/modules/templates/util_avatar.go
+++ b/modules/templates/util_avatar.go
@@ -30,7 +30,7 @@ func AvatarHTML(src string, size int, class, name string) template.HTML {
}
// Avatar renders user avatars. args: user, size (int), class (string)
-func Avatar(ctx context.Context, item interface{}, others ...interface{}) template.HTML {
+func Avatar(ctx context.Context, item any, others ...any) template.HTML {
size, class := gitea_html.ParseSizeAndClass(avatars.DefaultAvatarPixelSize, avatars.DefaultAvatarClass, others...)
switch t := item.(type) {
@@ -55,13 +55,13 @@ func Avatar(ctx context.Context, item interface{}, others ...interface{}) templa
}
// AvatarByAction renders user avatars from action. args: action, size (int), class (string)
-func AvatarByAction(ctx context.Context, action *activities_model.Action, others ...interface{}) template.HTML {
+func AvatarByAction(ctx context.Context, action *activities_model.Action, others ...any) template.HTML {
action.LoadActUser(ctx)
return Avatar(ctx, action.ActUser, others...)
}
// RepoAvatar renders repo avatars. args: repo, size(int), class (string)
-func RepoAvatar(repo *repo_model.Repository, others ...interface{}) template.HTML {
+func RepoAvatar(repo *repo_model.Repository, others ...any) template.HTML {
size, class := gitea_html.ParseSizeAndClass(avatars.DefaultAvatarPixelSize, avatars.DefaultAvatarClass, others...)
src := repo.RelAvatarLink()
@@ -72,7 +72,7 @@ func RepoAvatar(repo *repo_model.Repository, others ...interface{}) template.HTM
}
// AvatarByEmail renders avatars by email address. args: email, name, size (int), class (string)
-func AvatarByEmail(ctx context.Context, email, name string, others ...interface{}) template.HTML {
+func AvatarByEmail(ctx context.Context, email, name string, others ...any) template.HTML {
size, class := gitea_html.ParseSizeAndClass(avatars.DefaultAvatarPixelSize, avatars.DefaultAvatarClass, others...)
src := avatars.GenerateEmailAvatarFastLink(ctx, email, size*setting.Avatar.RenderedSizeFactor)
diff --git a/modules/templates/util_misc.go b/modules/templates/util_misc.go
index d11251fcdf..9cdabeb3ac 100644
--- a/modules/templates/util_misc.go
+++ b/modules/templates/util_misc.go
@@ -174,7 +174,7 @@ func FilenameIsImage(filename string) bool {
return strings.HasPrefix(mimeType, "image/")
}
-func TabSizeClass(ec interface{}, filename string) string {
+func TabSizeClass(ec any, filename string) string {
var (
value *editorconfig.Editorconfig
ok bool