ch4.8
This commit is contained in:
@@ -3,7 +3,6 @@ package main
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -15,20 +14,29 @@ func (app *application) home(w http.ResponseWriter, r *http.Request) {
|
||||
app.notFound(w)
|
||||
return
|
||||
}
|
||||
files := []string{
|
||||
"./ui/html/base.tmpl",
|
||||
"./ui/html/partials/nav.tmpl",
|
||||
"./ui/html/pages/home.tmpl",
|
||||
}
|
||||
ts, err := template.ParseFiles(files...)
|
||||
|
||||
snippets, err := app.snippets.Latest()
|
||||
if err != nil {
|
||||
app.serverError(w, err)
|
||||
return
|
||||
}
|
||||
err = ts.ExecuteTemplate(w, "base", nil)
|
||||
if err != nil {
|
||||
app.serverError(w, err)
|
||||
for _, snippet := range snippets {
|
||||
fmt.Fprintf(w, "%+v\n", snippet)
|
||||
}
|
||||
// files := []string{
|
||||
// "./ui/html/base.tmpl",
|
||||
// "./ui/html/partials/nav.tmpl",
|
||||
// "./ui/html/pages/home.tmpl",
|
||||
// }
|
||||
// ts, err := template.ParseFiles(files...)
|
||||
// if err != nil {
|
||||
// app.serverError(w, err)
|
||||
// return
|
||||
// }
|
||||
// err = ts.ExecuteTemplate(w, "base", nil)
|
||||
// if err != nil {
|
||||
// app.serverError(w, err)
|
||||
// }
|
||||
}
|
||||
|
||||
func (app *application) snippetView(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
Reference in New Issue
Block a user