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.
This commit is contained in:
2023-08-10 11:19:39 +08:00
committed by GitHub
parent 36eb3c433a
commit a370efc13f
54 changed files with 162 additions and 155 deletions

View File

@ -141,6 +141,7 @@ func Contexter() func(next http.Handler) http.Handler {
// TODO: "install.go" also shares the same logic, which should be refactored to a general function
ctx.TemplateContext = NewTemplateContext(ctx)
ctx.TemplateContext["Locale"] = ctx.Locale
ctx.TemplateContext["AvatarUtils"] = templates.NewAvatarUtils(ctx)
ctx.Data.MergeFrom(middleware.CommonTemplateContextData())
ctx.Data["Context"] = ctx // TODO: use "ctx" in template and remove this