form

package
v0.0.0-...-24e094a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTML

func HTML(t *template.Template, strct interface{}, errors ...FieldError) (template.HTML, error)

HTML is used to generate HTML forms/inputs from Go structs. Given a template that looks something like this:

<input type="{{.Type}}" name="{{.Name}}" {{with .Value}}value="{{.}}"{{end}}>

And a struct like this:

    struct{
	     Name string
      Email string
    }{
			 Name: "Michael Scott",
      Email: "michael@dundermifflin.com",
    }

The HTML function will return a template.HTML of:

<input type="text" name="Name" value="Michael Scott">
<input type="text" name="Email" value="michael@dundermifflin.com">

An example similar to this is shown as the first test case in TestHTML in the html_test.go source file.

Types

type FieldError

type FieldError struct {
	Field string
	Error string
}

FieldError is provided as a way to denote errors with specific fields.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL