template

package
v0.22.1 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exec

func Exec(command string, args []interface{}, inputs ...string) (string, error)

Exec runs external binary and returns its standard output. Used as custom template function.

func Get

func Get(path string, varArgs ...interface{}) (interface{}, error)

Get returns value in map by dot-separated key path. First argument is dot-separated key path. Second argument is default value if key not found and is optional. Third argument is map to search in. Used as custom template function.

func HasKey

func HasKey(path string, varArgs ...interface{}) (bool, error)

HasKey searches for any value by dot-separated key path in map. Used as custom template function.

func ReadFile

func ReadFile(file string) (string, error)

ReadFile reads file and returns its contents as string. Used as custom template function.

func Required

func Required(warn string, val interface{}) (interface{}, error)

Required returns error if val is nil of empty string. Otherwise it returns the same val. Used as custom template function.

func RequiredEnv

func RequiredEnv(name string) (string, error)

RequiredEnv returns environment variable by name and errors if it is not defined. Used as custom template function.

func ToYaml

func ToYaml(v interface{}) (string, error)

ToYaml renders data into YAML string. Used as custom template function.

func Tpl2yml

func Tpl2yml(tpl, yml string, data interface{}, templaterName string) error

Tpl2yml renders 'tpl' file to 'yml' file as go template.

Types

type Templater added in v0.17.0

type Templater interface {
	Name() string
	Render(string, interface{}) ([]byte, error)
}

Templater is interface for using different template function groups.

type Values

type Values = map[string]interface{}

Values is alias for string map of interfaces.

func FromYaml

func FromYaml(str string) (Values, error)

FromYaml parses YAML string into data. Used as custom template function.

func SetValueAtPath

func SetValueAtPath(path string, value interface{}, values Values) (Values, error)

SetValueAtPath sets value in map by dot-separated key path. Used as custom template function.

Jump to

Keyboard shortcuts

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