diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2023-08-10 11:19:39 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-10 11:19:39 +0800 |
commit | a370efc13f0e1ea309e324639832832bc14cb6dc (patch) | |
tree | 3c408cf225a4ffcc49f257fabf162831c92e23bf /routers/web/repo/blame.go | |
parent | 36eb3c433ae384f21beec63eb648141fb9dba676 (diff) | |
download | gitea-a370efc13f0e1ea309e324639832832bc14cb6dc.tar.gz gitea-a370efc13f0e1ea309e324639832832bc14cb6dc.zip |
Use template context function for avatar rendering (#26385)
Introduce `AvatarUtils`, no need to pass `$.Context` to every
sub-template, and simplify the template helper functions.
Diffstat (limited to 'routers/web/repo/blame.go')
-rw-r--r-- | routers/web/repo/blame.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/routers/web/repo/blame.go b/routers/web/repo/blame.go index 0e232c194c..b1cb42297c 100644 --- a/routers/web/repo/blame.go +++ b/routers/web/repo/blame.go @@ -235,6 +235,7 @@ func renderBlame(ctx *context.Context, blameParts []git.BlamePart, commitNames m var lexerName string + avatarUtils := templates.NewAvatarUtils(ctx) i := 0 commitCnt := 0 for _, part := range blameParts { @@ -257,9 +258,9 @@ func renderBlame(ctx *context.Context, blameParts []git.BlamePart, commitNames m var avatar string if commit.User != nil { - avatar = string(templates.Avatar(ctx, commit.User, 18, "gt-mr-3")) + avatar = string(avatarUtils.Avatar(commit.User, 18, "gt-mr-3")) } else { - avatar = string(templates.AvatarByEmail(ctx, commit.Author.Email, commit.Author.Name, 18, "gt-mr-3")) + avatar = string(avatarUtils.AvatarByEmail(commit.Author.Email, commit.Author.Name, 18, "gt-mr-3")) } br.Avatar = gotemplate.HTML(avatar) |