mvphelpers

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendAttr added in v0.2.1

func AppendAttr(buf StringByteWriter, k, v string)

func AppendAttrAny added in v0.2.1

func AppendAttrAny(buf StringByteWriter, k string, v any)

func Dict added in v0.2.1

func Dict(args ...any) map[string]any

func ExposeHelperPanic added in v0.2.1

func ExposeHelperPanic(e any)

ExposeHelperPanic helps to debug panics inside view helpers. Add the following call at the start of a panicing helper:

defer func() { mvphelpers.ExposeHelperPanic(recover()) }()

func FuncMap

func FuncMap() template.FuncMap

func FuzzyBool added in v0.2.1

func FuzzyBool(value any) bool

func FuzzyFloat64 added in v0.2.1

func FuzzyFloat64(v any) float64

func FuzzyHTML added in v0.2.1

func FuzzyHTML(v any) template.HTML

func FuzzyHTMLAttrValue added in v0.2.1

func FuzzyHTMLAttrValue(v any) template.HTMLAttr

func FuzzyHumanBool added in v0.2.2

func FuzzyHumanBool(str string) (bool, error)

FuzzyHumanBool is similar to strconv.ParseBool, but recognizes more on/off.

func FuzzyInt added in v0.2.1

func FuzzyInt(v any) int

func FuzzyInt64 added in v0.2.1

func FuzzyInt64(v any) int64

func FuzzyList added in v0.2.1

func FuzzyList(v any) []any

func IsEven added in v0.2.1

func IsEven(n any) bool

func IsOdd added in v0.2.1

func IsOdd(n any) bool

func JSONDict added in v0.2.2

func JSONDict(args ...any) template.JS

func List added in v0.2.1

func List(v ...any) []any

func OptionTag added in v0.2.2

func OptionTag(htmlValue string, modelValue, currentModelValue any, label any, attrs ...any) template.HTML

func Stringify added in v0.2.2

func Stringify(v any) string

func Subst added in v0.2.2

func Subst(str string, keysAndValues ...any) string

func SubstVars added in v0.2.2

func SubstVars(source string, isSourceRawHTML bool, prefix, suffix string, replace SubstReplaceFunc) template.HTML

func TryFuzzyInt added in v0.2.1

func TryFuzzyInt(v any) (int, bool)

func TryFuzzyInt64 added in v0.2.1

func TryFuzzyInt64(v any) (int64, bool)

Types

type Group

type Group struct {
	Index      int
	GroupSize  int
	GroupCount int
	Items      []any
}

func InGroupsOf

func InGroupsOf(n int, list any) []Group

func (Group) IsFirst

func (group Group) IsFirst() bool

func (Group) IsLast

func (group Group) IsLast() bool

func (Group) PlaceholderCount

func (group Group) PlaceholderCount() int

func (Group) Placeholders

func (group Group) Placeholders() []struct{}

type StringByteWriter added in v0.2.2

type StringByteWriter interface {
	io.StringWriter
	io.ByteWriter
}

type SubstReplaceFunc added in v0.2.2

type SubstReplaceFunc = func(buf *strings.Builder, key string)

func MakeReplaceFunc added in v0.2.2

func MakeReplaceFunc(values ...SubstValue) SubstReplaceFunc

type SubstValue added in v0.2.2

type SubstValue struct {
	Key     string
	Value   any
	Classes string
}

func SubstVal added in v0.2.2

func SubstVal(key string, value any, classes string) SubstValue

Jump to

Keyboard shortcuts

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