field

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Text   = Type("text")
	Toggle = Type("toggle")
	Int    = Type("integer")
	Float  = Type("float")
	Money  = Type("money")
	Meta   = Type("meta")
)

Built-in field types

Variables

This section is empty.

Functions

This section is empty.

Types

type Field

type Field struct {
	Name    string
	Type    Type
	Values  map[string]string
	Guarded bool
}

Field is a field of a page.

func New

func New(name string, typ Type, defaultValue string, opts ...Option) Field

New returns a new Field with the given name, Type and default value.

func NewFloat

func NewFloat(name string, defaultValue float64, opts ...Option) Field

NewFloat returns a Float field.

func NewInt

func NewInt(name string, defaultValue int, opts ...Option) Field

NewInt returns an Int field.

func NewMeta

func NewMeta(name string, defaultValue metadata.Data, opts ...Option) Field

NewMeta returns a Meta field.

func NewMoney

func NewMoney(name string, defaultValue money.Money, opts ...Option) Field

NewMoney returns a Money field.

func NewText

func NewText(name, defaultValue string, opts ...Option) Field

NewText returns a Text field.

func NewToggle

func NewToggle(name string, defaultValue bool, opts ...Option) Field

NewToggle returns a Toggle field.

func (Field) Value

func (f Field) Value(locale string) string

Value returns the value for the given locale as a string.

type Option

type Option func(*Field)

Option is a Field option.

func Guarded

func Guarded() Option

Guarded returns an Option that makes a Field guarded. A guarded Field cannot be removed from a Page.

func Localize

func Localize(val string, locales ...string) Option

Localize returns an Option that localizes a Field. val is used as the value for the given locales.

type Type

type Type string

Type is a field type.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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