{{template "name" pipeline}} 是什么意思
what does {{template "name" pipeline}} mean
在https://golang.org/pkg/text/template/#hdr-Actions中有如下解释
{{template "name" pipeline}} The template with the specified name is
executed with dot set to the value of the pipeline.
这是什么意思?什么是点?
比如我看到下面的模板代码-
{{ define "header" }}
{{ template "top" . }}
{{ template "needs" }}
...
{{ end }}
什么是“.”遵循上面代码中的 "top"?
值“.”是 third paragraph in the documentation:
中解释的当前值或光标
Annotations in the template refer to elements of the data structure (typically a field of a struct or a key in a map) to control execution and derive values to be displayed. Execution of the template walks the structure and sets the cursor, represented by a period '.' and called "dot", to the value at the current location in the structure as execution proceeds.
命令{{ template "top" . }}
以点作为参数执行模板"top"。在 "top" 中,点被设置为参数。
在https://golang.org/pkg/text/template/#hdr-Actions中有如下解释
{{template "name" pipeline}} The template with the specified name is executed with dot set to the value of the pipeline.
这是什么意思?什么是点?
比如我看到下面的模板代码-
{{ define "header" }}
{{ template "top" . }}
{{ template "needs" }}
...
{{ end }}
什么是“.”遵循上面代码中的 "top"?
值“.”是 third paragraph in the documentation:
中解释的当前值或光标Annotations in the template refer to elements of the data structure (typically a field of a struct or a key in a map) to control execution and derive values to be displayed. Execution of the template walks the structure and sets the cursor, represented by a period '.' and called "dot", to the value at the current location in the structure as execution proceeds.
命令{{ template "top" . }}
以点作为参数执行模板"top"。在 "top" 中,点被设置为参数。