Fix rendering

This commit is contained in:
soup 2024-11-16 14:30:07 -05:00
parent cf950db825
commit 920f162695
2 changed files with 36 additions and 0 deletions

View file

@ -1,5 +1,39 @@
{{define "attrs"}}
name="{{.Name}}"
placeholder="{{.Placeholder}}"
aria-invalid="{{not .Valid}}"
{{if .Error}}
aria-describedby="{{.Name}}-error"
{{end}}
{{end}}
{{define "field"}} {{define "field"}}
<mu-field>
<label>
{{.Label}}
{{if eq .Type "textarea"}}
<textarea
{{template "attrs" .}}
>{{.Value}}</textarea>
{{else}}
<input
type="{{.Type}}"
value="{{.Value}}"
{{template "attrs" .}}
>
{{end}}
</label>
{{if .Error}}
<small id="{{.Name}}-error">{{.Error}}</small>
{{end}}
</mu-field>
{{end}} {{end}}
{{define "form"}} {{define "form"}}
<form action="{{.Action}}" method="{{.Method}}">
{{range .Fields}}
{{template "field" .}}
{{end}}
<input type="submit" value="Submit">
</form>
{{end}} {{end}}

View file

@ -1,3 +1,4 @@
{{define "page"}}
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
@ -23,3 +24,4 @@
{{block "BodyAfter" .BodyAfter}}{{end}} {{block "BodyAfter" .BodyAfter}}{{end}}
</body> </body>
</html> </html>
{{end}}