Documentation
¶
Overview ¶
Package template provides utility functions around reading and writing templates.
Index ¶
- func CopyData(src map[string]interface{}) (map[string]interface{}, error)
- func FlattenData(src map[string]interface{}, fis []*FlattenInfo) (map[string]interface{}, error)
- func MergeData(dst map[string]interface{}, src map[string]interface{}) error
- func WriteBuffer(text string, data map[string]interface{}) (*bytes.Buffer, error)
- func WriteDir(inputDir, outputDir string, data map[string]interface{}) error
- func WriteFile(in, out string, data map[string]interface{}) error
- type FlattenInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FlattenData ¶
func FlattenData(src map[string]interface{}, fis []*FlattenInfo) (map[string]interface{}, error)
FlattenData returns the map of kes from src flattened into a single map.
func MergeData ¶
MergeData merges template data from src to dst. For all keys in flatten it will pop the key and merge back into dst.
func WriteBuffer ¶
WriteBuffer creates a buffer with template `text` filled with values from `data`.
Types ¶
type FlattenInfo ¶
type FlattenInfo struct { Key string `hcl:"key,attr" json:"key"` Index *int `hcl:"index,optional" json:"index,omitempty"` }
FlattenInfo describes keys to flatten. If index is not a nil pointer then it is assumed the value is a list that must be flattened at the specific index.
Click to show internal directories.
Click to hide internal directories.