Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

fix FuncMap

aichy126149751153c8f
diff --git a/internal/base/server/http.go b/internal/base/server/http.go
index 408c7d82..17e4eec3 100644
--- a/internal/base/server/http.go
+++ b/internal/base/server/http.go
@@ -64,7 +64,7 @@ func NewHTTPServer(debug bool,
cmsauthV1.Use(authUserMiddleware.CmsAuth())
answerRouter.RegisterAnswerCmsAPIRouter(cmsauthV1)
- r.SetFuncMap(template.FuncMap{
+ funcMap := template.FuncMap{
"templateHTML": func(data string) template.HTML {
return template.HTML(data)
},
@@ -138,14 +138,15 @@ func NewHTTPServer(debug bool,
"timezone": tz,
}
},
- })
+ }
+ r.SetFuncMap(funcMap)
dev := os.Getenv("DEVCODE")
if dev != "" {
r.LoadHTMLGlob("../../ui/template/*")
} else {
html, _ := fs.Sub(ui.Template, "template")
- htmlTemplate := template.Must(template.New("").ParseFS(html, "*.html"))
+ htmlTemplate := template.Must(template.New("").Funcs(funcMap).ParseFS(html, "*.html"))
r.SetHTMLTemplate(htmlTemplate)
}