fix(layout):修复布局模板执行时的数据传递问题- 修改 ExecuteTemplate 方法调用,确保布局模板能正确接收原始数据

- 更新 product_list.html 模板中的占位符内容- 在 store_layout.html 中添加 body 占位符以支持内容插入
This commit is contained in:
2025-11-08 11:19:56 +08:00
parent 6ee7e672d6
commit fe70f35703
3 changed files with 8 additions and 2 deletions

View File

@@ -38,7 +38,7 @@ func (proc *LayoutTemplateProcessor) ExecTemplateWithFunc(writer io.Writer, name
err = localTemplates.ExecuteTemplate(&sb, name, data)
if layoutName != "" {
// 通过布局模板加载内容
err = localTemplates.ExecuteTemplate(writer, layoutName, sb.String())
err = localTemplates.ExecuteTemplate(writer, layoutName, data)
} else {
_, err = io.WriteString(writer, sb.String())
}

View File

@@ -8,4 +8,8 @@
{{ define "right_column" }}
Put something useful here
{{ end }}
{{ . }}
{{ end }}
{{ . }}

View File

@@ -18,6 +18,8 @@
<div class="col-9">
{{ template "right_column" . }}
</div>
{{ body }}
</div>
</body>
</html>