diff options
author | Runxi Yu <me@runxiyu.org> | 2025-04-05 23:59:17 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-04-05 23:59:17 +0800 |
commit | 0c0062b22ff4ddac9cf8c4ef84116eddba99bce2 (patch) | |
tree | 2d1790cdf42b0dcdb3f82f77cea2b86fb7a42120 /resources.go | |
parent | scfg: Remove tests for now (diff) | |
download | forge-0c0062b22ff4ddac9cf8c4ef84116eddba99bce2.tar.gz forge-0c0062b22ff4ddac9cf8c4ef84116eddba99bce2.tar.zst forge-0c0062b22ff4ddac9cf8c4ef84116eddba99bce2.zip |
templates shall no longer be a global variable
Diffstat (limited to 'resources.go')
-rw-r--r-- | resources.go | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/resources.go b/resources.go index e2168a3..514c0ae 100644 --- a/resources.go +++ b/resources.go @@ -20,10 +20,8 @@ var embeddedSourceFS embed.FS //go:embed hookc/hookc git2d/git2d var embeddedResourcesFS embed.FS -var templates *template.Template //nolint:gochecknoglobals - // loadTemplates minifies and loads HTML templates. -func loadTemplates() (err error) { +func (s *Server) loadTemplates() (err error) { minifier := minify.New() minifierOptions := html.Minifier{ TemplateDelims: [2]string{"{{", "}}"}, @@ -31,7 +29,7 @@ func loadTemplates() (err error) { } //exhaustruct:ignore minifier.Add("text/html", &minifierOptions) - templates = template.New("templates").Funcs(template.FuncMap{ + s.templates = template.New("templates").Funcs(template.FuncMap{ "first_line": misc.FirstLine, "path_escape": misc.PathEscape, "query_escape": misc.QueryEscape, @@ -54,7 +52,7 @@ func loadTemplates() (err error) { return err } - _, err = templates.Parse(misc.BytesToString(minified)) + _, err = s.templates.Parse(misc.BytesToString(minified)) if err != nil { return err } |