summaryrefslogtreecommitdiffstats
path: root/modules/test
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2023-08-08 09:22:47 +0800
committerGitHub <noreply@github.com>2023-08-08 01:22:47 +0000
commit69130532239ee7ade82977f456c12826e1adeb1e (patch)
tree81b8131bedc592af753481b7d222263b2c2655dc /modules/test
parent0c6ae61229bce9d9ad3d359cee927464968a2dd1 (diff)
downloadgitea-69130532239ee7ade82977f456c12826e1adeb1e.tar.gz
gitea-69130532239ee7ade82977f456c12826e1adeb1e.zip
Start using template context function (#26254)
Before: * `{{.locale.Tr ...}}` * `{{$.locale.Tr ...}}` * `{{$.root.locale.Tr ...}}` * `{{template "sub" .}}` * `{{template "sub" (dict "locale" $.locale)}}` * `{{template "sub" (dict "root" $)}}` * ..... With context function: only need to `{{ctx.Locale.Tr ...}}` The "ctx" could be considered as a super-global variable for all templates including sub-templates. To avoid potential risks (any bug in the template context function package), this PR only starts using "ctx" in "head.tmpl" and "footer.tmpl" and it has a "DataRaceCheck". If there is anything wrong, the code can be fixed or reverted easily.
Diffstat (limited to 'modules/test')
-rw-r--r--modules/test/context_tests.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/modules/test/context_tests.go b/modules/test/context_tests.go
index 9e7095e116..92d7f8b22b 100644
--- a/modules/test/context_tests.go
+++ b/modules/test/context_tests.go
@@ -150,11 +150,11 @@ func LoadGitRepo(t *testing.T, ctx *context.Context) {
type mockRender struct{}
-func (tr *mockRender) TemplateLookup(tmpl string) (templates.TemplateExecutor, error) {
+func (tr *mockRender) TemplateLookup(tmpl string, _ gocontext.Context) (templates.TemplateExecutor, error) {
return nil, nil
}
-func (tr *mockRender) HTML(w io.Writer, status int, _ string, _ any) error {
+func (tr *mockRender) HTML(w io.Writer, status int, _ string, _ any, _ gocontext.Context) error {
if resp, ok := w.(http.ResponseWriter); ok {
resp.WriteHeader(status)
}