Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Templates tmpl.Execute和子文件golang_Templates_Go - Fatal编程技术网

Templates tmpl.Execute和子文件golang

Templates tmpl.Execute和子文件golang,templates,go,Templates,Go,我需要帮助。 我需要在子文件(“article.html”,文本中的示例)中使用“html/template”的标记({.Title}},示例): core.tmpl中的代码: {{template "article"}} {{define "article"}} {{.Title}}<br><br> {{.Page.Test}} {{end}} article.tmpl中的代码: {{template "article"}} {{define "article"}

我需要帮助。 我需要在子文件(
“article.html”
,文本中的示例)中使用
“html/template”
的标记(
{.Title}}
,示例):

core.tmpl中的代码:

{{template "article"}}
{{define "article"}}
{{.Title}}<br><br>
{{.Page.Test}}
{{end}}
article.tmpl中的代码:

{{template "article"}}
{{define "article"}}
{{.Title}}<br><br>
{{.Page.Test}}
{{end}}
{{定义“文章”}
{{.Title}}

{{.Page.Test} {{end}
核心.tmpl中,您必须使用

{{template "article" .}}
如果未在末尾指定
,则将使用
nil
数据执行模板。指定
的值传递给调用的模板

引用程序包文档中的操作部分:

{{template "name"}}
    The template with the specified name is executed with nil data.

{{template "name" pipeline}}
    The template with the specified name is executed with dot set
    to the value of the pipeline.