Move static template helper func to controllers package
This commit is contained in:
20
controllers/static.go
Normal file
20
controllers/static.go
Normal 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) }
|
||||
}
|
||||
Reference in New Issue
Block a user