// This design would allow us to have 1- or 2-depth nested templates. // // Everything uses rootTmpl, and everything has access to all // componentTmpls. But each combinedTmpl only uses the named template in // layoutTmpls, except `page-*` which are defined under rootTmpl only. package main import ( "fmt" "os" "strings" "text/template" ) func main() { rootTmpl := template.Must(template.New("").Parse(`Page > {{ template "root" }} {{ template "footer" }}`)) componentTmpls := []*template.Template{ template.Must(template.New("header").Parse("
")), template.Must(template.New("footer").Parse("