fix: register FuncMap for settings template

This commit is contained in:
Claus Lohmar 2026-07-10 12:27:19 +01:00
parent 1e37c33603
commit 2e21aa8bea

View file

@ -416,7 +416,7 @@ func settingsHandler(w http.ResponseWriter, r *http.Request) {
lang = "en" lang = "en"
} }
tmpl := template.Must(template.New("settings").Parse(settingsHTML)) tmpl := template.Must(template.New("settings").Funcs(funcMap).Parse(settingsHTML))
w.Header().Set("Content-Type", "text/html; charset=utf-8") w.Header().Set("Content-Type", "text/html; charset=utf-8")
tmpl.Execute(w, map[string]interface{}{ tmpl.Execute(w, map[string]interface{}{
"User": user, "User": user,
@ -579,7 +579,10 @@ func publicSettingsHandler(w http.ResponseWriter, r *http.Request) {
// --- Translation system --- // --- Translation system ---
var translations = make(map[string]map[string]string) var translations = make(map[string]map[string]string)
var launcherTmpl *template.Template var (
launcherTmpl *template.Template
funcMap template.FuncMap
)
var adminTmpl *template.Template var adminTmpl *template.Template
func loadTranslations(lngDir string) { func loadTranslations(lngDir string) {
@ -1311,7 +1314,7 @@ func main() {
loadTranslations(lngDir) loadTranslations(lngDir)
// Create template FuncMap for translations // Create template FuncMap for translations
funcMap := template.FuncMap{"t": t} funcMap = template.FuncMap{"t": t}
// Parse templates with FuncMap // Parse templates with FuncMap
launcherTmpl = template.Must(template.New("launcher").Funcs(funcMap).Parse(launcherHTML)) launcherTmpl = template.Must(template.New("launcher").Funcs(funcMap).Parse(launcherHTML))