text/template: new, simpler API
The Set type is gone. Instead, templates are automatically associated by
being parsed together; nested definitions implicitly create associations.
Only associated templates can invoke one another.
This approach dramatically reduces the breadth of the construction API.
For now, html/template is deleted from src/pkg/Makefile, so this can
be checked in. Nothing in the tree depends on it. It will be updated next.
R=dsymonds, adg, rsc, r, gri, mikesamuel, nigeltao
CC=golang-dev
https://golang.org/cl/5415060
diff --git a/doc/codelab/wiki/final-noclosure.go b/doc/codelab/wiki/final-noclosure.go
index 2d42106..bc08f25 100644
--- a/doc/codelab/wiki/final-noclosure.go
+++ b/doc/codelab/wiki/final-noclosure.go
@@ -68,7 +68,7 @@
}
func renderTemplate(w http.ResponseWriter, tmpl string, p *Page) {
- t, err := template.ParseFile(tmpl + ".html")
+ t, err := template.ParseFiles(tmpl + ".html")
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
diff --git a/doc/codelab/wiki/final-noerror.go b/doc/codelab/wiki/final-noerror.go
index 53433e9..535550b 100644
--- a/doc/codelab/wiki/final-noerror.go
+++ b/doc/codelab/wiki/final-noerror.go
@@ -33,14 +33,14 @@
if err != nil {
p = &Page{Title: title}
}
- t, _ := template.ParseFile("edit.html")
+ t, _ := template.ParseFiles("edit.html")
t.Execute(w, p)
}
func viewHandler(w http.ResponseWriter, r *http.Request) {
title := r.URL.Path[lenPath:]
p, _ := loadPage(title)
- t, _ := template.ParseFile("view.html")
+ t, _ := template.ParseFiles("view.html")
t.Execute(w, p)
}
diff --git a/doc/codelab/wiki/final-parsetemplate.go b/doc/codelab/wiki/final-parsetemplate.go
index e3d8a97..aca4fbb 100644
--- a/doc/codelab/wiki/final-parsetemplate.go
+++ b/doc/codelab/wiki/final-parsetemplate.go
@@ -55,7 +55,7 @@
}
func renderTemplate(w http.ResponseWriter, tmpl string, p *Page) {
- t, err := template.ParseFile(tmpl+".html", nil)
+ t, err := template.ParseFiles(tmpl+".html", nil)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
diff --git a/doc/codelab/wiki/final-template.go b/doc/codelab/wiki/final-template.go
index 0230ae5..f8ab1c6 100644
--- a/doc/codelab/wiki/final-template.go
+++ b/doc/codelab/wiki/final-template.go
@@ -51,7 +51,7 @@
}
func renderTemplate(w http.ResponseWriter, tmpl string, p *Page) {
- t, _ := template.ParseFile(tmpl+".html", nil)
+ t, _ := template.ParseFiles(tmpl+".html", nil)
t.Execute(w, p)
}
diff --git a/doc/codelab/wiki/final.go b/doc/codelab/wiki/final.go
index 66f19c1..94e685b 100644
--- a/doc/codelab/wiki/final.go
+++ b/doc/codelab/wiki/final.go
@@ -58,7 +58,7 @@
func init() {
for _, tmpl := range []string{"edit", "view"} {
- t := template.Must(template.ParseFile(tmpl + ".html"))
+ t := template.Must(template.ParseFiles(tmpl + ".html"))
templates[tmpl] = t
}
}
diff --git a/doc/codelab/wiki/index.html b/doc/codelab/wiki/index.html
index 08e181e..ae71a40 100644
--- a/doc/codelab/wiki/index.html
+++ b/doc/codelab/wiki/index.html
@@ -476,7 +476,7 @@
if err != nil {
p = &Page{Title: title}
}
- t, _ := template.ParseFile("edit.html")
+ t, _ := template.ParseFiles("edit.html")
t.Execute(w, p)
}
</pre>
@@ -530,7 +530,7 @@
func viewHandler(w http.ResponseWriter, r *http.Request) {
title := r.URL.Path[lenPath:]
p, _ := loadPage(title)
- t, _ := template.ParseFile("view.html")
+ t, _ := template.ParseFiles("view.html")
t.Execute(w, p)
}
</pre>
@@ -558,7 +558,7 @@
}
func renderTemplate(w http.ResponseWriter, tmpl string, p *Page) {
- t, _ := template.ParseFile(tmpl+".html", nil)
+ t, _ := template.ParseFiles(tmpl+".html", nil)
t.Execute(w, p)
}
</pre>
@@ -643,7 +643,7 @@
<pre>
func renderTemplate(w http.ResponseWriter, tmpl string, p *Page) {
- t, err := template.ParseFile(tmpl+".html", nil)
+ t, err := template.ParseFiles(tmpl+".html", nil)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
@@ -719,7 +719,7 @@
<pre>
func init() {
for _, tmpl := range []string{"edit", "view"} {
- t := template.Must(template.ParseFile(tmpl + ".html"))
+ t := template.Must(template.ParseFiles(tmpl + ".html"))
templates[tmpl] = t
}
}