example page fixed
This commit is contained in:
parent
9f741eecbe
commit
c0b4e92a57
@ -7,17 +7,17 @@ import (
|
||||
|
||||
func ExampleHandler(w http.ResponseWriter, r *http.Request) {
|
||||
data := PageData{
|
||||
Title: "Example Page",
|
||||
}
|
||||
|
||||
tmpl, err := template.ParseFiles("web/views/#layout.html", "web/views/example.html")
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
Title: "Example Page",
|
||||
}
|
||||
|
||||
err = tmpl.ExecuteTemplate(w, "layout", data)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
tmpl, err := template.ParseFiles("web/views/#layout.html", "web/views/example.html", "web/views/#header.html", "web/views/#footer.html")
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
err = tmpl.ExecuteTemplate(w, "layout", data)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,11 @@
|
||||
{{define "view"}}
|
||||
<header>
|
||||
<h1 class="mt-8 mb-8 text-3xl font-bold text-blue-300">
|
||||
This is an additional example route
|
||||
</h1>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<section>
|
||||
<h1 class="font-bold">Serve Static Files Like this Globe</h1>
|
||||
<h1 class="font-bold">Serve Static Files Like this Gopher</h1>
|
||||
|
||||
<button hx-get="/" class="p-2 text-white bg-blue-400 rounded-md">
|
||||
Click Me!
|
||||
</button>
|
||||
<img src="/static/img/gopher.png" alt="alternate text">
|
||||
</main>
|
||||
|
||||
<footer>
|
||||
<p>© 2024 My Web App</p>
|
||||
</footer>
|
||||
{{end}}
|
||||
|
Loading…
Reference in New Issue
Block a user