define

block 語句一起使用:

{{ block "main" . }}
  {{ print "如果 'main' 範本為空,顯示預設值" }}
{{ end }}

{{ define "main" }}
  <h1>{{ .Title }}</h1>
  {{ .Content }}
{{ end }}

partial 函數一起使用:

{{ partial "inline/foo.html" (dict "answer" 42) }}

{{ define "partials/inline/foo.html" }}
  {{ printf "答案是 %v。" .answer }}
{{ end }}

template 函數一起使用:

{{ template "foo" (dict "answer" 42) }}

{{ define "foo" }}
  {{ printf "答案是 %v。" .answer }}
{{ end }}

查看 Go 的 text/template 文件以獲得更多資訊。