-
-
-
-
-
- - - - -- -
-
-
- - - - -- -
-
diff --git a/main.go b/main.go index 7ba66e1..0f95903 100644 --- a/main.go +++ b/main.go @@ -38,17 +38,22 @@ type Todo struct { Completed bool } +type ViewModel struct { + Todos []Todo +} + func main() { t := New() http.Handle("/public/", http.FileServer(http.FS(publicFS))) http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - err := t.Render(w, "list.html", nil) - if err != nil { - log.Println(err) + vm := ViewModel{ + Todos: []Todo{ + {Title: "One"}, + {Title: "Two", Completed: true}, + {Title: "Three"}, + }, } - }) - http.HandleFunc("/show", func(w http.ResponseWriter, r *http.Request) { - err := t.Render(w, "show.html", nil) + err := t.Render(w, "list.html", vm) if err != nil { log.Println(err) } diff --git a/views/_footer.html b/views/_footer.html new file mode 100644 index 0000000..2a68497 --- /dev/null +++ b/views/_footer.html @@ -0,0 +1,5 @@ + diff --git a/views/_head.html b/views/_head.html new file mode 100644 index 0000000..3347357 --- /dev/null +++ b/views/_head.html @@ -0,0 +1,5 @@ + + +