diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2024-11-05 14:04:26 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-05 14:04:26 +0800 |
commit | 4a469c8e1b3c1d153316aec9fd8cbdd3e1dd54e8 (patch) | |
tree | 3fc7eae5668299c7dbd5933cd14839bbccacefdd /services/context | |
parent | b068dbd40ee3b4dc7d18cdcf168f0c24cea234c0 (diff) | |
download | gitea-4a469c8e1b3c1d153316aec9fd8cbdd3e1dd54e8.tar.gz gitea-4a469c8e1b3c1d153316aec9fd8cbdd3e1dd54e8.zip |
Refactor template ctx and render utils (#32422)
Clean up the templates
Diffstat (limited to 'services/context')
-rw-r--r-- | services/context/context.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/services/context/context.go b/services/context/context.go index 42f7c3d9d1..6c7128ef68 100644 --- a/services/context/context.go +++ b/services/context/context.go @@ -100,6 +100,7 @@ func NewTemplateContextForWeb(ctx *Context) TemplateContext { tmplCtx := NewTemplateContext(ctx) tmplCtx["Locale"] = ctx.Base.Locale tmplCtx["AvatarUtils"] = templates.NewAvatarUtils(ctx) + tmplCtx["RenderUtils"] = templates.NewRenderUtils(ctx) tmplCtx["RootData"] = ctx.Data tmplCtx["Consts"] = map[string]any{ "RepoUnitTypeCode": unit.TypeCode, @@ -154,7 +155,9 @@ func Contexter() func(next http.Handler) http.Handler { ctx := NewWebContext(base, rnd, session.GetContextSession(req)) ctx.Data.MergeFrom(middleware.CommonTemplateContextData()) - ctx.Data["Context"] = ctx // TODO: use "ctx" in template and remove this + if setting.IsProd && !setting.IsInTesting { + ctx.Data["Context"] = ctx // TODO: use "ctx" in template and remove this + } ctx.Data["CurrentURL"] = setting.AppSubURL + req.URL.RequestURI() ctx.Data["Link"] = ctx.Link |