From a52e76c0da8169795743c5b0b78cd13caaff0842 Mon Sep 17 00:00:00 2001 From: Lucas Schumacher Date: Wed, 14 Aug 2024 12:48:36 -0400 Subject: [PATCH] Use template fn errors to fail when the correct fn has not been assigned yet --- views/template.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/views/template.go b/views/template.go index 40c4fc5..211e9f2 100644 --- a/views/template.go +++ b/views/template.go @@ -42,6 +42,11 @@ func (t Template) TestTemplate(data interface{}) error { if err != nil { return err } + tpl = tpl.Funcs(template.FuncMap{ + "csrfField": func() template.HTML { + return `` + }, + }) return tpl.Execute(&testWriter, data) } @@ -52,8 +57,8 @@ func FromFile(pattern ...string) (Template, error) { func FromFS(fs fs.FS, pattern ...string) (Template, error) { tpl := template.New(pattern[0]) tpl = tpl.Funcs(template.FuncMap{ - "csrfField": func() template.HTML { - return `` + "csrfField": func() (template.HTML, error) { + return ``, fmt.Errorf("csrfField Not Implimented") }, }) tpl, err := tpl.ParseFS(fs, pattern...)