formautomator

package module
v0.0.0-...-3bad917 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2019 License: MIT Imports: 8 Imported by: 0

README

formautomator

Create HTML Forms Automatically

JSON metadata

{
    "method": "POST",
    "action": "/addr",
    "fields": [
        {
            "name": "address",
            "label": "Address",
            "class": "form-control",
            "type": "text",
            "placeholder": "Sunset Blvd, 38"
        }
    ]
}

Usage examples

cat examples/example.json| go run cmd/fa/main.go -t ./templates
go run cmd/fa/main.go -f examples/example.json -t ./templates

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TemplateFunctions = template.FuncMap{
	"in": in,
}

Functions

func CreateForm

func CreateForm(j json.RawMessage, templates []string) (string, error)

CreateForm generate an HTML form

Types

type Field

type Field struct {
	Name        string   `json:"name,omitempty"`
	Label       string   `json:"label,omitempty"`
	Class       string   `json:"class,omitempty"`
	Type        string   `json:"type,omitempty"`
	Placeholder string   `json:"placeholder,omitempty"`
	Value       string   `json:"value,omitempty"`
	Metadata    Metadata `json:"metadata,omitempty"`
}

Field properties

type Form

type Form struct {
	Fields []Field `json:"fields,omitempty"`
	Method string  `json:"method,omitempty"`
	Action string  `json:"action,omitempty"`
}

type Metadata

type Metadata struct {
	ForList string `json:"form_list,omitempty"`
	Index   string `json:"index,omitempty"`
	Label   string `json:"label,omitempty"`
	Var     string `json:"var,omitempty"`
}

Directories

Path Synopsis
cmd
fa

Jump to

Keyboard shortcuts

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