使用文本/模板:
将其渲染到标准输出的代码
t := template.Must(template.ParseFiles("main.tmpl", "head.tmpl", "foot.tmpl"))
t.Execute(os.Stdout, nil)
main.tmpl:
{{template "header" .}}
<p>main content</p>
{{template "footer" .}}
脚.tmpl:
{{define "footer"}}
<footer>This is the foot</footer>
{{end}}
head.tmpl:
{{define "header"}}
<header>This is the head</header>
{{end}}
这将导致:
<header>This is the head</header>
<p>main content</p>
<footer>This is the foot</footer>
使用 html/template 将非常相似。
如何查看浏览器?没有终端!