1
0
mirror of https://github.com/golang/go synced 2024-11-24 05:10:19 -07:00

doc: update codelab wiki to fix template.Execute argument order

Fixes #1595.

R=r
CC=golang-dev
https://golang.org/cl/4243067
This commit is contained in:
Andrew Gerrand 2011-03-09 12:59:13 +11:00
parent 758d05551d
commit 4896b17584
5 changed files with 9 additions and 9 deletions

View File

@ -73,7 +73,7 @@ func renderTemplate(w http.ResponseWriter, tmpl string, p *Page) {
http.Error(w, err.String(), http.StatusInternalServerError)
return
}
err = t.Execute(p, w)
err = t.Execute(w, p)
if err != nil {
http.Error(w, err.String(), http.StatusInternalServerError)
}

View File

@ -35,14 +35,14 @@ func editHandler(w http.ResponseWriter, r *http.Request) {
p = &Page{Title: title}
}
t, _ := template.ParseFile("edit.html", nil)
t.Execute(p, w)
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", nil)
t.Execute(p, w)
t.Execute(w, p)
}
func main() {

View File

@ -61,7 +61,7 @@ func renderTemplate(w http.ResponseWriter, tmpl string, p *Page) {
http.Error(w, err.String(), http.StatusInternalServerError)
return
}
err = t.Execute(p, w)
err = t.Execute(w, p)
if err != nil {
http.Error(w, err.String(), http.StatusInternalServerError)
}

View File

@ -53,7 +53,7 @@ func saveHandler(w http.ResponseWriter, r *http.Request) {
func renderTemplate(w http.ResponseWriter, tmpl string, p *Page) {
t, _ := template.ParseFile(tmpl+".html", nil)
t.Execute(p, w)
t.Execute(w, p)
}
func main() {

View File

@ -475,7 +475,7 @@ func editHandler(w http.ResponseWriter, r *http.Request) {
p = &Page{Title: title}
}
t, _ := template.ParseFile("edit.html", nil)
t.Execute(p, w)
t.Execute(w, p)
}
</pre>
@ -527,7 +527,7 @@ func viewHandler(w http.ResponseWriter, r *http.Request) {
title := r.URL.Path[lenPath:]
p, _ := loadPage(title)
t, _ := template.ParseFile(&#34;view.html&#34;, nil)
t.Execute(p, w)
t.Execute(w, p)
}
</pre>
@ -555,7 +555,7 @@ func editHandler(w http.ResponseWriter, r *http.Request) {
func renderTemplate(w http.ResponseWriter, tmpl string, p *Page) {
t, _ := template.ParseFile(tmpl+&#34;.html&#34;, nil)
t.Execute(p, w)
t.Execute(w, p)
}
</pre>
@ -644,7 +644,7 @@ func renderTemplate(w http.ResponseWriter, tmpl string, p *Page) {
http.Error(w, err.String(), http.StatusInternalServerError)
return
}
err = t.Execute(p, w)
err = t.Execute(w, p)
if err != nil {
http.Error(w, err.String(), http.StatusInternalServerError)
}