Move static template helper func to controllers package

This commit is contained in:
2024-08-01 09:56:00 -04:00
parent 140230d89b
commit 13bf91ba7d
2 changed files with 24 additions and 19 deletions

20
controllers/static.go Normal file
View File

@@ -0,0 +1,20 @@
package controllers
import (
"git.kealoha.me/lks/lenslocked/templates"
"git.kealoha.me/lks/lenslocked/views"
"net/http"
"strings"
)
func StaticTemplate(templatePath string) http.HandlerFunc {
tpl := views.Must(views.FromFS(templates.FS, templatePath))
var testWriter strings.Builder
err := tpl.ExecuteWriter(&testWriter, nil)
if err != nil {
panic(err)
}
return func(w http.ResponseWriter, r *http.Request) { tpl.Execute(w, nil) }
}