diff options
Diffstat (limited to '')
-rw-r--r-- | templ/form.tpl | 3 | ||||
-rw-r--r-- | templ/login.tpl | 2 | ||||
-rw-r--r-- | templ/template.go | 4 |
3 files changed, 7 insertions, 2 deletions
diff --git a/templ/form.tpl b/templ/form.tpl index b17cb1d..deb8d58 100644 --- a/templ/form.tpl +++ b/templ/form.tpl @@ -9,6 +9,9 @@ {{with .Class}}class="{{.}}"{{end}} {{range .Options}} {{.}} {{end}} > + {{range errors}} + <p style="color:red">{{.}}</p> + {{end}} {{with .Footer}}<p>{{.}}</p>{{end}} <br /> {{end}}
\ No newline at end of file diff --git a/templ/login.tpl b/templ/login.tpl index 40d49c9..d704365 100644 --- a/templ/login.tpl +++ b/templ/login.tpl @@ -1,6 +1,6 @@ {{define "body"}} <form action="/login" method="post"> - {{inputs_for .}} + {{inputs_and_errors_for . .Errors}} <button type="submit">Log In!</button> </form> {{end}}
\ No newline at end of file diff --git a/templ/template.go b/templ/template.go index 20a4de7..d68c752 100644 --- a/templ/template.go +++ b/templ/template.go @@ -18,7 +18,9 @@ var baseTpl *template.Template var formBuilder form.Builder func init() { - baseTpl = template.Must(template.ParseFS(fs, "base.tpl", "form.tpl")) + baseTpl = template.Must(template.New("base.tpl"). + Funcs(form.FuncMap()). + ParseFS(fs, "base.tpl", "form.tpl")) formBuilder = form.Builder{InputTemplate: baseTpl.Lookup("formItem")} baseTpl.Funcs(formBuilder.FuncMap()) } |