fix(templates):修复模板加载错误处理

- 在 ParseGlob 方法后添加错误检查
- 打印详细的错误信息以便调试- 确保在发生错误时函数能正确返回
This commit is contained in:
2025-11-09 15:49:43 +08:00
parent 6e04c9747b
commit 35837fc136
2 changed files with 4 additions and 2 deletions

View File

@@ -22,9 +22,7 @@ func LoadTemplates(c config.Configuration) (err error) {
fmt.Printf("设置模板 getTemplates 函数开始\n")
doLoad := func() (t *template.Template) {
fmt.Printf("设置模板 getTemplates doLoad 函数已执行\n")
t = template.New("htmlTemplates")
t.Funcs(map[string]interface{}{
"body": func() string { return "" },
@@ -32,6 +30,10 @@ func LoadTemplates(c config.Configuration) (err error) {
"handler": func() interface{} { return "" },
})
t, err = t.ParseGlob(path)
if err != nil {
fmt.Printf("获取模板 getTemplates doLoad %v 错误: %v \n", path, err)
return
}
return
}

Binary file not shown.