template

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2020 License: MPL-2.0, MPL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteBuffered

func ExecuteBuffered(body string, data interface{}) (b bytes.Buffer, err error)

func ExpandFromStringMap

func ExpandFromStringMap(data map[string]string, toExpand ...*string) error

ExpandFromStringMap expands placeholders in each input string based on the input key/value map.

Types

type StringMapBuilder

type StringMapBuilder struct {
	// contains filtered or unexported fields
}

StringMapBuilder supports use cases where a given template string will be expanded multiple times with different sets of key/value pairs, and the data map is composed from combinations of map[string]string and struct values which are convertible to the former.

An empty string value will be remain empty if its key is registered by SetExpectedKey. If the key "K" is not expected, the value will be replaced by "{{.K}}" to allow a later expansion to provide a value.

func NewStringMapBuilder

func NewStringMapBuilder() *StringMapBuilder

func (*StringMapBuilder) Map

func (d *StringMapBuilder) Map() map[string]string

Map returns the currently built key/value map.

func (*StringMapBuilder) Merge

func (d *StringMapBuilder) Merge(mode cage_structs.MergeMode, maps ...interface{}) *StringMapBuilder

Merge augments the key/value map with one or more map[string]map values.

func (*StringMapBuilder) SetExpectedKey

func (d *StringMapBuilder) SetExpectedKey(k ...string) *StringMapBuilder

SetExpectedKey configures the builder to replace the input keys in Map instead of retaining them as placeholders for a future expanasion when they are expected.

Jump to

Keyboard shortcuts

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