template

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2021 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 interface{}) string

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

func GetFieldFormatted

func GetFieldFormatted(item interface{}, f FieldInfo) (interface{}, error)

func GetFieldsFormatted

func GetFieldsFormatted(item interface{}, fs []FieldInfo) ([]interface{}, error)

GetFieldsFormatted returns an interface{} 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 interface{}, fs []FieldInfo) []interface{}

GetFieldsFormattedForce returns an interface{} 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