YamlForm

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

README

YamlForm

A simple Go library that creates a HTML form based on the inputted YAML

Usage

import "codeberg.org/ThinkingSecurityWorks/YamlForm"

func main() {
	yf := &YamlForm{}
	html, err := yf.Render(yaml, map[string]string)
	if err != nil {
		panic(err)
    }
	fmt.Println(html)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Field

type Field struct {
	Name  string            `yaml:"name" validate:"required"`
	Type  string            `yaml:"type" validate:"required,oneof=text number date email password tel url textarea file"`
	Attrs map[string]string `yaml:"attrs"`
}

func (*Field) GetNormalName

func (f *Field) GetNormalName() string

type Form

type Form struct {
	Explanation string  `yaml:"explanation" validate:"required"`
	Fields      []Field `yaml:"fields"`
}

type YamlForm

type YamlForm struct {
	ExplanationClass         string
	LabelClass               string
	InputClass               string
	ExplanationPreRenderHook func(string) (string, error)
	Debug                    bool
}

func (*YamlForm) Render

func (y *YamlForm) Render(inputYaml []byte, values map[string]string) (string, error)

Jump to

Keyboard shortcuts

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