From 6e04c9747becccbcaf5f4e09cc65cb091b294f4e Mon Sep 17 00:00:00 2001 From: yanzuoguang Date: Sun, 9 Nov 2025 15:44:15 +0800 Subject: [PATCH] =?UTF-8?q?fix(templates):=20=E5=A2=9E=E5=BC=BA=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E5=8A=A0=E8=BD=BD=E5=92=8C=E6=89=A7=E8=A1=8C=E7=9A=84?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E5=A4=84=E7=90=86-=20=E5=9C=A8=20layout=5Fex?= =?UTF-8?q?ecutor.go=20=E4=B8=AD=E6=B7=BB=E5=8A=A0=E4=BA=86=E5=AF=B9=20get?= =?UTF-8?q?Templates=20=E8=BF=94=E5=9B=9E=E5=80=BC=E7=9A=84=E7=A9=BA?= =?UTF-8?q?=E6=8C=87=E9=92=88=E6=A3=80=E6=9F=A5=20-=20=E5=BD=93=20getTempl?= =?UTF-8?q?ates=E6=9C=AA=E5=AE=9A=E4=B9=89=E6=88=96=E8=BF=94=E5=9B=9E=20ni?= =?UTF-8?q?l=20=E6=97=B6=EF=BC=8C=E6=89=93=E5=8D=B0=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E5=B9=B6=E6=8F=90=E5=89=8D=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=20-=20=E5=9C=A8=20template=5Floader.go=20=E4=B8=AD=E5=BC=95?= =?UTF-8?q?=E5=85=A5=20fmt=20=E5=8C=85=E7=94=A8=E4=BA=8E=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E8=BE=93=E5=87=BA=20-=20=E5=9C=A8=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E5=8A=A0=E8=BD=BD=E9=80=BB=E8=BE=91=E4=B8=AD=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E8=B0=83=E8=AF=95=E4=BF=A1=E6=81=AF=E6=89=93=E5=8D=B0?= =?UTF-8?q?=EF=BC=8C=E4=BE=BF=E4=BA=8E=E8=BF=BD=E8=B8=AA=20getTemplates=20?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E6=89=A7=E8=A1=8C=E7=8A=B6=E6=80=81=20-=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=20doLoad=20=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E7=9A=84=E8=B0=83=E8=AF=95=E6=97=A5=E5=BF=97?= =?UTF-8?q?=EF=BC=8C=E5=B8=AE=E5=8A=A9=E5=AE=9A=E4=BD=8D=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../platform/templates/layout_executor.go | 4 ++++ .../platform/templates/template_loader.go | 7 +++++++ 32-platform/sportsstore/store.db | Bin 20480 -> 20480 bytes 3 files changed, 11 insertions(+) diff --git a/32-platform/platform/templates/layout_executor.go b/32-platform/platform/templates/layout_executor.go index 2b8c243..ad94b27 100644 --- a/32-platform/platform/templates/layout_executor.go +++ b/32-platform/platform/templates/layout_executor.go @@ -27,6 +27,10 @@ func (proc *LayoutTemplateProcessor) ExecTemplateWithFunc(writer io.Writer, name layoutName := "" // 获取模板列表 localTemplates := getTemplates() + if localTemplates == nil { + fmt.Printf("获取模板失败, getTemplates 没有定义 : %v 模板参数: %v \n", name, data) + return + } // 执行函数 localTemplates.Funcs(map[string]interface{}{ // 替换body内容 diff --git a/32-platform/platform/templates/template_loader.go b/32-platform/platform/templates/template_loader.go index def0227..b48c564 100644 --- a/32-platform/platform/templates/template_loader.go +++ b/32-platform/platform/templates/template_loader.go @@ -2,6 +2,7 @@ package templates import ( "errors" + "fmt" "html/template" "platform/config" "sync" @@ -17,7 +18,13 @@ func LoadTemplates(c config.Configuration) (err error) { } reload := c.GetBoolDefault("templates:reload", false) once.Do(func() { + + 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 "" }, diff --git a/32-platform/sportsstore/store.db b/32-platform/sportsstore/store.db index 19d4dfae4d83a9a9c2d5e7bca9fa111e78c09abe..8ba1aa259222159a417eb3d7050c68d5a92d9f40 100644 GIT binary patch delta 91 zcmZozz}T>Wae}nqTLuOORv?Cfc@uSv8Q*S9;OAjv-dw<=#l*<6c{X3BpcoVX1_u6X jKmwwkg|CdyiH~iwpuij6&1`o67#FiB2yA9?_`?qXi>wse delta 91 zcmZozz}T>Wae}nqLk0#0Rv?CfX%lsf86R#;;OAjv*<8S*#l*6Cc}VL4h~Co7wdKF>YpY_`?qXgVYqd