mirror of
https://github.com/aljazceru/njump.git
synced 2025-12-24 01:34:21 +01:00
actually fix the templates.
This commit is contained in:
15
render.go
15
render.go
@@ -19,6 +19,9 @@ import (
|
|||||||
//go:embed static/*
|
//go:embed static/*
|
||||||
var static embed.FS
|
var static embed.FS
|
||||||
|
|
||||||
|
//go:embed templates/*
|
||||||
|
var templates embed.FS
|
||||||
|
|
||||||
func render(w http.ResponseWriter, r *http.Request) {
|
func render(w http.ResponseWriter, r *http.Request) {
|
||||||
fmt.Println(r.URL.Path, ":~", r.Header.Get("user-agent"))
|
fmt.Println(r.URL.Path, ":~", r.Header.Get("user-agent"))
|
||||||
w.Header().Set("Content-Type", "text/html")
|
w.Header().Set("Content-Type", "text/html")
|
||||||
@@ -187,12 +190,14 @@ func render(w http.ResponseWriter, r *http.Request) {
|
|||||||
"SanitizeString": html.EscapeString,
|
"SanitizeString": html.EscapeString,
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpl := template.Must(template.New("event").
|
tmpl := template.Must(
|
||||||
Funcs(funcMap).
|
template.New("tmpl").
|
||||||
ParseFS(static))
|
Funcs(funcMap).
|
||||||
|
ParseFS(templates, "templates/*"),
|
||||||
|
)
|
||||||
|
|
||||||
if err := tmpl.ExecuteTemplate(w, "event", params); err != nil {
|
if err := tmpl.ExecuteTemplate(w, "note.html", params); err != nil {
|
||||||
http.Error(w, "error rendering: "+err.Error(), 500)
|
log.Error().Err(err).Msg("error rendering")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user