diff --git a/templates/tailwind.gohtml b/templates/tailwind.gohtml index 12aa03d..f4c7096 100644 --- a/templates/tailwind.gohtml +++ b/templates/tailwind.gohtml @@ -16,12 +16,15 @@ FAQ
diff --git a/views/template.go b/views/template.go index 8b49727..cac9cce 100644 --- a/views/template.go +++ b/views/template.go @@ -11,6 +11,8 @@ import ( "os" "strings" + userctx "git.kealoha.me/lks/lenslocked/context" + "git.kealoha.me/lks/lenslocked/models" "github.com/gorilla/csrf" ) @@ -27,7 +29,8 @@ func (t Template) Execute(w http.ResponseWriter, r *http.Request, data interface } tpl = tpl.Funcs(template.FuncMap{ - "csrfField": func() template.HTML { return csrf.TemplateField(r) }, + "csrfField": func() template.HTML { return csrf.TemplateField(r) }, + "currentUser": func() *models.User { return userctx.User(r.Context()) }, }) w.Header().Set("Content-Type", "text/html; charset=utf8") @@ -40,6 +43,7 @@ func (t Template) Execute(w http.ResponseWriter, r *http.Request, data interface } io.Copy(w, &buf) } + func (t Template) TestTemplate(data interface{}) error { var testWriter strings.Builder tpl, err := t.htmlTpl.Clone() @@ -50,6 +54,9 @@ func (t Template) TestTemplate(data interface{}) error { "csrfField": func() template.HTML { return `