From 934df3f098c33bcbb1493a420833817b80518020 Mon Sep 17 00:00:00 2001 From: René 'Necoro' Neumann Date: Sun, 11 Feb 2024 23:45:56 +0100 Subject: Include form handling --- templ/template.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'templ/template.go') diff --git a/templ/template.go b/templ/template.go index 8fed965..20a4de7 100644 --- a/templ/template.go +++ b/templ/template.go @@ -4,6 +4,8 @@ import ( "embed" "html/template" "sync" + + "github.com/Necoro/form" ) //go:embed *.tpl @@ -13,9 +15,12 @@ var templates = make(map[string]*template.Template) var muTpl sync.RWMutex var baseTpl *template.Template +var formBuilder form.Builder func init() { - baseTpl = template.Must(template.ParseFS(fs, "base.tpl")) + baseTpl = template.Must(template.ParseFS(fs, "base.tpl", "form.tpl")) + formBuilder = form.Builder{InputTemplate: baseTpl.Lookup("formItem")} + baseTpl.Funcs(formBuilder.FuncMap()) } func Lookup(name string) *template.Template { -- cgit v1.2.3-54-g00ecf