This commit is contained in:
lbenedar
2026-03-04 17:25:25 +03:00
parent c5833c6ddf
commit dceefea953
2 changed files with 39 additions and 11 deletions

View File

@@ -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) {