Files
the-way-to-go_ZH_CN/eBook/examples/chapter_15/template_with_end.go
2019-07-15 19:55:54 -07:00

22 lines
335 B
Go

// template_with_end.go
package main
import (
"os"
"text/template"
)
func main() {
t := template.New("test")
t, _ = t.Parse("{{with `hello`}}{{.}}{{end}}!\n")
t.Execute(os.Stdout, nil)
t, _ = t.Parse("{{with `hello`}}{{.}} {{with `Mary`}}{{.}}{{end}}{{end}}!\n")
t.Execute(os.Stdout, nil)
}
/* Output:
hello!
hello Mary!
*/