summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Lemon <y@yulqen.org>2024-02-08 15:53:08 +0000
committerMatthew Lemon <y@yulqen.org>2024-02-08 15:53:08 +0000
commit4bcba90a1a78cac4ec2ed370bb751d95717b7120 (patch)
tree93584524be69f3072660b42fc301a914a45ceb2b
parent0d7989c353d06397e18e4562d97b4b0cd2160a0e (diff)
First proper use of templates
-rw-r--r--cmd/web/handlers.go2
-rw-r--r--ui/html/base.tmpl.html9
-rw-r--r--ui/html/pages/home.tmpl.html6
3 files changed, 14 insertions, 3 deletions
diff --git a/cmd/web/handlers.go b/cmd/web/handlers.go
index 7a8f79e..fd70c5e 100644
--- a/cmd/web/handlers.go
+++ b/cmd/web/handlers.go
@@ -31,7 +31,7 @@ func (app *application) home(w http.ResponseWriter, r *http.Request) {
files := []string{
"./ui/html/base.tmpl.html",
- // "./ui/html/pages/home.tmpl.html",
+ "./ui/html/pages/home.tmpl.html",
// "./ui/html/partials/nav.tmpl.html",
}
diff --git a/ui/html/base.tmpl.html b/ui/html/base.tmpl.html
index 77ea1e9..f7f7e48 100644
--- a/ui/html/base.tmpl.html
+++ b/ui/html/base.tmpl.html
@@ -4,10 +4,15 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
- <title>DED</title>
+ <title>{{ template "title" .}} - DED</title>
</head>
<body>
- <h1>Hello from DED!</h1>
+ <header>
+ <h1><a href="/">DED</a></h1>
+ </header>
+ <main>
+ {{ template "main" }}
+ </main>
</body>
</html>
{{ end }}
diff --git a/ui/html/pages/home.tmpl.html b/ui/html/pages/home.tmpl.html
new file mode 100644
index 0000000..882a3ba
--- /dev/null
+++ b/ui/html/pages/home.tmpl.html
@@ -0,0 +1,6 @@
+{{define "title"}}Home{{end}}
+
+{{ define "main" }}
+<h2>Data</h2>
+<p>There is nothing to see here yet.</p>
+{{ end }}