diff options
author | Gabriel Arakaki Giovanini <mail@gabrielgio.me> | 2023-06-25 16:03:36 +0200 |
---|---|---|
committer | Gabriel Arakaki Giovanini <mail@gabrielgio.me> | 2023-06-25 16:12:05 +0200 |
commit | d6cf67b3d7747b6274d92e394d75d348060fa5f5 (patch) | |
tree | 8c48f947e7ab732a38b15eab6a898cb14caa1669 /tmpl.go | |
parent | 57b41ad766b3c4505672c12f058f10c7a132dd5b (diff) | |
download | lens-d6cf67b3d7747b6274d92e394d75d348060fa5f5.tar.gz lens-d6cf67b3d7747b6274d92e394d75d348060fa5f5.tar.bz2 lens-d6cf67b3d7747b6274d92e394d75d348060fa5f5.zip |
feat: Add static file to output bin
Now the final binary has a standalone web server including necessary
static file.
Diffstat (limited to 'tmpl.go')
-rw-r--r-- | tmpl.go | 29 |
1 files changed, 0 insertions, 29 deletions
diff --git a/tmpl.go b/tmpl.go deleted file mode 100644 index b11f962..0000000 --- a/tmpl.go +++ /dev/null @@ -1,29 +0,0 @@ -package img - -import ( - "embed" - "fmt" - "html/template" - "io" -) - -//go:embed templates/*.html -var TemplateFS embed.FS - -var Template *template.Template - -type HTMLView[T any] struct { - Title string - Username string - Data T -} - -func Render[T any](w io.Writer, page string, view *HTMLView[T]) error { - pageFile := fmt.Sprintf("templates/%s", page) - tmpl, err := template.New("").ParseFS(TemplateFS, "templates/layout.html", pageFile) - if err != nil { - return err - } - - return tmpl.ExecuteTemplate(w, page, view) -} |