summaryrefslogtreecommitdiff
path: root/app/views
diff options
context:
space:
mode:
Diffstat (limited to 'app/views')
-rw-r--r--app/views/dashboard/show.html.tmpl27
-rw-r--r--app/views/render.go27
2 files changed, 54 insertions, 0 deletions
diff --git a/app/views/dashboard/show.html.tmpl b/app/views/dashboard/show.html.tmpl
new file mode 100644
index 0000000..5293117
--- /dev/null
+++ b/app/views/dashboard/show.html.tmpl
@@ -0,0 +1,27 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <meta name="color-scheme" content="light dark">
+ <title>SparkleLab</title>
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css">
+ </head>
+ <body>
+ <main class="container">
+ <nav>
+ <ul>
+ <li><strong>SparkleLab</strong></li>
+ </ul>
+ <ul>
+ <li><a href="/session/new">Login</a></li>
+ </ul>
+ </nav>
+ {{range .Sparkles}}
+ <div>{{ . }}</div>
+ {{else}}
+ <div><strong>No Sparkles</strong></div>
+ {{end}}
+ </main>
+ </body>
+</html>
diff --git a/app/views/render.go b/app/views/render.go
new file mode 100644
index 0000000..d06a4f7
--- /dev/null
+++ b/app/views/render.go
@@ -0,0 +1,27 @@
+package views
+
+import (
+ "embed"
+ "html/template"
+ "io"
+)
+
+//go:embed **/*.html.tmpl
+var fs embed.FS
+
+func Get(path string) (*template.Template, error) {
+ return template.ParseFS(fs, path+".html.tmpl")
+}
+
+func Render[T any](w io.Writer, path string, data T) error {
+ tmpl, err := Get(path)
+ if err != nil {
+ return err
+ }
+
+ if err := tmpl.Execute(w, data); err != nil {
+ return err
+ }
+
+ return nil
+}