Documentation ¶
Index ¶
- func GetNestedParam(keyStr, separator string, candidates ...Params) (interface{}, error)
- func GetNestedParamFn(keyStr, separator string, lookupFn func(key string) interface{}) (interface{}, string, map[string]interface{}, error)
- func GetString(m map[string]interface{}, key string) string
- func PrepareParams(m Params)
- func ToSliceStringMap(in interface{}) ([]map[string]interface{}, error)
- func ToStringMap(in interface{}) map[string]interface{}
- func ToStringMapBool(in interface{}) map[string]bool
- func ToStringMapE(in interface{}) (map[string]interface{}, error)
- func ToStringMapString(in interface{}) map[string]string
- func ToStringMapStringE(in interface{}) (map[string]string, error)
- type KeyRenamer
- type Params
- func (p Params) DeleteMergeStrategy() bool
- func (p Params) Get(indices ...string) interface{}
- func (p Params) GetMergeStrategy() (ParamsMergeStrategy, bool)
- func (p Params) IsZero() bool
- func (p Params) Merge(pp Params)
- func (p Params) MergeRoot(pp Params)
- func (p Params) Set(pp Params)
- func (p Params) SetDefaultMergeStrategy(s ParamsMergeStrategy)
- type ParamsMergeStrategy
- type Scratch
- func (c *Scratch) Add(key string, newAddend interface{}) (string, error)
- func (c *Scratch) Delete(key string) string
- func (c *Scratch) DeleteInMap(key string, mapKey string) string
- func (c *Scratch) Get(key string) interface{}
- func (c *Scratch) GetSortedMapValues(key string) interface{}
- func (c *Scratch) Set(key string, value interface{}) string
- func (c *Scratch) SetInMap(key string, mapKey string, value interface{}) string
- func (c *Scratch) Values() map[string]interface{}
- type Scratcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetNestedParam ¶ added in v0.56.0
GetNestedParam gets the first match of the keyStr in the candidates given. It will first try the exact match and then try to find it as a nested map value, using the given separator, e.g. "mymap.name". It assumes that all the maps given have lower cased keys.
func GetNestedParamFn ¶ added in v0.56.0
func GetString ¶ added in v0.57.0
GetString tries to get a value with key from map m and convert it to a string. It will return an empty string if not found or if it cannot be convertd to a string.
func PrepareParams ¶ added in v0.84.0
func PrepareParams(m Params)
PrepareParams * makes all the keys in the given map lower cased and will do so * This will modify the map given. * Any nested map[interface{}]interface{}, map[string]interface{},map[string]string will be converted to Params. * Any _merge value will be converted to proper type and value.
func ToSliceStringMap ¶ added in v0.77.0
ToSliceStringMap converts in to []map[string]interface{}.
func ToStringMap ¶ added in v0.60.0
func ToStringMap(in interface{}) map[string]interface{}
ToStringMap converts in to map[string]interface{}.
func ToStringMapBool ¶ added in v0.84.0
ToStringMapBool converts in to bool.
func ToStringMapE ¶ added in v0.60.0
ToStringMapE converts in to map[string]interface{}.
func ToStringMapString ¶ added in v0.84.0
ToStringMapString converts in to map[string]string.
func ToStringMapStringE ¶ added in v0.84.0
ToStringMapStringE converts in to map[string]string.
Types ¶
type KeyRenamer ¶ added in v0.54.0
type KeyRenamer struct {
// contains filtered or unexported fields
}
KeyRenamer supports renaming of keys in a map.
func NewKeyRenamer ¶ added in v0.54.0
func NewKeyRenamer(patternKeys ...string) (KeyRenamer, error)
NewKeyRenamer creates a new KeyRenamer given a list of pattern and new key value pairs.
func (KeyRenamer) Rename ¶ added in v0.54.0
func (r KeyRenamer) Rename(m map[string]interface{})
Rename renames the keys in the given map according to the patterns in the current KeyRenamer.
type Params ¶ added in v0.60.0
type Params map[string]interface{}
Params is a map where all keys are lower case.
func MustToParamsAndPrepare ¶ added in v0.84.1
func MustToParamsAndPrepare(in interface{}) Params
MustToParamsAndPrepare calls ToParamsAndPrepare and panics if it fails.
func ToParamsAndPrepare ¶ added in v0.84.0
ToParamsAndPrepare converts in to Params and prepares it for use. If in is nil, an empty map is returned. See PrepareParams.
func (Params) DeleteMergeStrategy ¶ added in v0.84.0
func (Params) Get ¶ added in v0.60.0
Get does a lower case and nested search in this map. It will return nil if none found.
func (Params) GetMergeStrategy ¶ added in v0.84.0
func (p Params) GetMergeStrategy() (ParamsMergeStrategy, bool)
func (Params) Merge ¶ added in v0.84.0
Merge transfers values from pp to p for new keys. This is done recursively.
func (Params) MergeRoot ¶ added in v0.88.0
MergeRoot transfers values from pp to p for new keys where p is the root of the tree. This is done recursively.
func (Params) Set ¶ added in v0.84.0
Set overwrites values in p with values in pp for common or new keys. This is done recursively.
func (Params) SetDefaultMergeStrategy ¶ added in v0.84.0
func (p Params) SetDefaultMergeStrategy(s ParamsMergeStrategy)
type ParamsMergeStrategy ¶ added in v0.84.0
type ParamsMergeStrategy string
ParamsMergeStrategy tells what strategy to use in Params.Merge.
const ( // Do not merge. ParamsMergeStrategyNone ParamsMergeStrategy = "none" // Only add new keys. ParamsMergeStrategyShallow ParamsMergeStrategy = "shallow" // Add new keys, merge existing. ParamsMergeStrategyDeep ParamsMergeStrategy = "deep" )
type Scratch ¶ added in v0.45.1
type Scratch struct {
// contains filtered or unexported fields
}
Scratch is a writable context used for stateful operations in Page/Node rendering.
func NewScratch ¶ added in v0.45.1
func NewScratch() *Scratch
NewScratch returns a new instance of Scratch.
func (*Scratch) Add ¶ added in v0.45.1
Add will, for single values, add (using the + operator) the addend to the existing addend (if found). Supports numeric values and strings.
If the first add for a key is an array or slice, then the next value(s) will be appended.
func (*Scratch) DeleteInMap ¶ added in v0.84.0
DeleteInMap deletes a value to a map with the given key in the Node context.
func (*Scratch) GetSortedMapValues ¶ added in v0.45.1
GetSortedMapValues returns a sorted map previously filled with SetInMap.
func (*Scratch) Set ¶ added in v0.45.1
Set stores a value with the given key in the Node context. This value can later be retrieved with Get.
func (*Scratch) SetInMap ¶ added in v0.45.1
SetInMap stores a value to a map with the given key in the Node context. This map can later be retrieved with GetSortedMapValues.