Commit 4896b175 authored by Andrew Gerrand's avatar Andrew Gerrand

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

Fixes #1595.

R=r
CC=golang-dev
https://golang.org/cl/4243067
parent 758d0555
...@@ -73,7 +73,7 @@ func renderTemplate(w http.ResponseWriter, tmpl string, p *Page) { ...@@ -73,7 +73,7 @@ func renderTemplate(w http.ResponseWriter, tmpl string, p *Page) {
http.Error(w, err.String(), http.StatusInternalServerError) http.Error(w, err.String(), http.StatusInternalServerError)
return return
} }
err = t.Execute(p, w) err = t.Execute(w, p)
if err != nil { if err != nil {
http.Error(w, err.String(), http.StatusInternalServerError) http.Error(w, err.String(), http.StatusInternalServerError)
} }
......
...@@ -35,14 +35,14 @@ func editHandler(w http.ResponseWriter, r *http.Request) { ...@@ -35,14 +35,14 @@ func editHandler(w http.ResponseWriter, r *http.Request) {
p = &Page{Title: title} p = &Page{Title: title}
} }
t, _ := template.ParseFile("edit.html", nil) t, _ := template.ParseFile("edit.html", nil)
t.Execute(p, w) t.Execute(w, p)
} }
func viewHandler(w http.ResponseWriter, r *http.Request) { func viewHandler(w http.ResponseWriter, r *http.Request) {
title := r.URL.Path[lenPath:] title := r.URL.Path[lenPath:]
p, _ := loadPage(title) p, _ := loadPage(title)
t, _ := template.ParseFile("view.html", nil) t, _ := template.ParseFile("view.html", nil)
t.Execute(p, w) t.Execute(w, p)
} }
func main() { func main() {
......
...@@ -61,7 +61,7 @@ func renderTemplate(w http.ResponseWriter, tmpl string, p *Page) { ...@@ -61,7 +61,7 @@ func renderTemplate(w http.ResponseWriter, tmpl string, p *Page) {
http.Error(w, err.String(), http.StatusInternalServerError) http.Error(w, err.String(), http.StatusInternalServerError)
return return
} }
err = t.Execute(p, w) err = t.Execute(w, p)
if err != nil { if err != nil {
http.Error(w, err.String(), http.StatusInternalServerError) http.Error(w, err.String(), http.StatusInternalServerError)
} }
......
...@@ -53,7 +53,7 @@ func saveHandler(w http.ResponseWriter, r *http.Request) { ...@@ -53,7 +53,7 @@ func saveHandler(w http.ResponseWriter, r *http.Request) {
func renderTemplate(w http.ResponseWriter, tmpl string, p *Page) { func renderTemplate(w http.ResponseWriter, tmpl string, p *Page) {
t, _ := template.ParseFile(tmpl+".html", nil) t, _ := template.ParseFile(tmpl+".html", nil)
t.Execute(p, w) t.Execute(w, p)
} }
func main() { func main() {
......
...@@ -475,7 +475,7 @@ func editHandler(w http.ResponseWriter, r *http.Request) { ...@@ -475,7 +475,7 @@ func editHandler(w http.ResponseWriter, r *http.Request) {
p = &Page{Title: title} p = &Page{Title: title}
} }
t, _ := template.ParseFile("edit.html", nil) t, _ := template.ParseFile("edit.html", nil)
t.Execute(p, w) t.Execute(w, p)
} }
</pre> </pre>
...@@ -527,7 +527,7 @@ func viewHandler(w http.ResponseWriter, r *http.Request) { ...@@ -527,7 +527,7 @@ func viewHandler(w http.ResponseWriter, r *http.Request) {
title := r.URL.Path[lenPath:] title := r.URL.Path[lenPath:]
p, _ := loadPage(title) p, _ := loadPage(title)
t, _ := template.ParseFile(&#34;view.html&#34;, nil) t, _ := template.ParseFile(&#34;view.html&#34;, nil)
t.Execute(p, w) t.Execute(w, p)
} }
</pre> </pre>
...@@ -555,7 +555,7 @@ func editHandler(w http.ResponseWriter, r *http.Request) { ...@@ -555,7 +555,7 @@ func editHandler(w http.ResponseWriter, r *http.Request) {
func renderTemplate(w http.ResponseWriter, tmpl string, p *Page) { func renderTemplate(w http.ResponseWriter, tmpl string, p *Page) {
t, _ := template.ParseFile(tmpl+&#34;.html&#34;, nil) t, _ := template.ParseFile(tmpl+&#34;.html&#34;, nil)
t.Execute(p, w) t.Execute(w, p)
} }
</pre> </pre>
...@@ -644,7 +644,7 @@ func renderTemplate(w http.ResponseWriter, tmpl string, p *Page) { ...@@ -644,7 +644,7 @@ func renderTemplate(w http.ResponseWriter, tmpl string, p *Page) {
http.Error(w, err.String(), http.StatusInternalServerError) http.Error(w, err.String(), http.StatusInternalServerError)
return return
} }
err = t.Execute(p, w) err = t.Execute(w, p)
if err != nil { if err != nil {
http.Error(w, err.String(), http.StatusInternalServerError) http.Error(w, err.String(), http.StatusInternalServerError)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment