fix(layout):修复布局模板执行时的数据传递问题- 修改 ExecuteTemplate 方法调用,确保布局模板能正确接收原始数据
- 更新 product_list.html 模板中的占位符内容- 在 store_layout.html 中添加 body 占位符以支持内容插入
This commit is contained in:
@@ -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())
|
||||
}
|
||||
|
||||
@@ -8,4 +8,8 @@
|
||||
{{ define "right_column" }}
|
||||
Put something useful here
|
||||
|
||||
{{ end }}
|
||||
{{ . }}
|
||||
{{ end }}
|
||||
|
||||
|
||||
{{ . }}
|
||||
@@ -18,6 +18,8 @@
|
||||
<div class="col-9">
|
||||
{{ template "right_column" . }}
|
||||
</div>
|
||||
|
||||
{{ body }}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user