template

package
v0.7.8 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute(pattern string, item any) string

Execute takes a template string and an `any` struct, substituting struct values for the variables. Field names can be nested.

func GetFieldFormatted

func GetFieldFormatted(item any, f FieldInfo) (any, error)

func GetFieldsFormatted

func GetFieldsFormatted(item any, fs []FieldInfo) ([]any, error)

GetFieldsFormatted returns an `any` slice for the struct and fields requested. An error is returned if any fields are not found or parsing options fail.

func GetFieldsFormattedForce

func GetFieldsFormattedForce(item any, fs []FieldInfo) []any

GetFieldsFormattedForce returns an `any` slice for the struct and fields requested. An empty string value is returned for anything that encounters an error.

Types

type FieldInfo

type FieldInfo struct {
	Name    string // . separated name path
	Type    string // . separated type path
	Options []string
}

func ParseFieldInfoString

func ParseFieldInfoString(fieldsRawStr string) []FieldInfo

Jump to

Keyboard shortcuts

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