From a370efc13f0e1ea309e324639832832bc14cb6dc Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Thu, 10 Aug 2023 11:19:39 +0800 Subject: 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. --- templates/shared/issuelist.tmpl | 2 +- templates/shared/user/avatarlink.tmpl | 2 +- templates/shared/user/org_profile_avatar.tmpl | 2 +- templates/shared/user/profile_big_avatar.tmpl | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'templates/shared') diff --git a/templates/shared/issuelist.tmpl b/templates/shared/issuelist.tmpl index 30e19baf7c..72cf1dd6c8 100644 --- a/templates/shared/issuelist.tmpl +++ b/templates/shared/issuelist.tmpl @@ -37,7 +37,7 @@
{{range .Assignees}} - {{avatar $.Context . 20}} + {{ctx.AvatarUtils.Avatar . 20}} {{end}}
diff --git a/templates/shared/user/avatarlink.tmpl b/templates/shared/user/avatarlink.tmpl index c99f0aacb7..5e3ed7a68c 100644 --- a/templates/shared/user/avatarlink.tmpl +++ b/templates/shared/user/avatarlink.tmpl @@ -1 +1 @@ -{{avatar $.Context .user}} +{{ctx.AvatarUtils.Avatar .user}} diff --git a/templates/shared/user/org_profile_avatar.tmpl b/templates/shared/user/org_profile_avatar.tmpl index a56763e288..9c94930511 100644 --- a/templates/shared/user/org_profile_avatar.tmpl +++ b/templates/shared/user/org_profile_avatar.tmpl @@ -3,7 +3,7 @@
- {{avatar $.Context . 100}} + {{ctx.AvatarUtils.Avatar . 100}} {{.DisplayName}} {{if .Visibility.IsLimited}}
{{$.locale.Tr "org.settings.visibility.limited_shortname"}}
{{end}} diff --git a/templates/shared/user/profile_big_avatar.tmpl b/templates/shared/user/profile_big_avatar.tmpl index 97afbb6580..305a6b5a20 100644 --- a/templates/shared/user/profile_big_avatar.tmpl +++ b/templates/shared/user/profile_big_avatar.tmpl @@ -3,11 +3,11 @@ {{if eq .SignedUserID .ContextUser.ID}} {{/* the size doesn't take affect (and no need to take affect), image size(width) should be controlled by the parent container since this is not a flex layout*/}} - {{avatar $.Context .ContextUser 256}} + {{ctx.AvatarUtils.Avatar .ContextUser 256}} {{else}} - {{avatar $.Context .ContextUser 256}} + {{ctx.AvatarUtils.Avatar .ContextUser 256}} {{end}}
@@ -86,7 +86,7 @@ {{if (or .Visibility.IsPublic (and ($.SignedUser) (or .Visibility.IsLimited (and (.HasMemberWithUserID $.SignedUserID) .Visibility.IsPrivate) ($.IsAdmin))))}}
  • - {{avatar $.Context .}} + {{ctx.AvatarUtils.Avatar .}}
  • {{end}} -- cgit v1.2.3