mirror of
https://github.com/golang/go
synced 2024-11-24 07:20:02 -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:
parent
758d05551d
commit
4896b17584
@ -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)
|
||||
}
|
||||
|
@ -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() {
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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() {
|
||||
|
@ -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("view.html", 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+".html", 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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user