Template bug fix

This commit is contained in:
Eliot Whalan 2016-06-23 19:00:17 +10:00
parent 8f1a9a04e8
commit 588f5b3510
No known key found for this signature in database
GPG Key ID: C0A42175139840D6
1 changed files with 2 additions and 3 deletions

View File

@ -218,8 +218,6 @@ func getPaste(paste string) string {
} }
var templates = template.Must(template.ParseFiles("assets/paste.html"))
func pasteHandler(w http.ResponseWriter, r *http.Request) { func pasteHandler(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r) vars := mux.Vars(r)
paste := vars["pasteId"] paste := vars["pasteId"]
@ -228,10 +226,11 @@ func pasteHandler(w http.ResponseWriter, r *http.Request) {
Title: paste, Title: paste,
Body: []byte(s), Body: []byte(s),
} }
err := templates.ExecuteTemplate(w, "assets/paste.html", p) t, err := template.ParseFiles("assets/edit.html")
if err != nil { if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
} }
t.Execute(w, p)
} }
func rawHandler(w http.ResponseWriter, r *http.Request) { func rawHandler(w http.ResponseWriter, r *http.Request) {