package maps
import "github.com/gohugoio/hugo/common/maps"
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 ToLower(m Params)
- func ToStringMap(in interface{}) map[string]interface{}
- func ToStringMapE(in interface{}) (map[string]interface{}, error)
- type KeyRenamer
- func NewKeyRenamer(patternKeys ...string) (KeyRenamer, error)
- func (r KeyRenamer) Rename(m map[string]interface{})
- type Params
- type Scratch
- func NewScratch() *Scratch
- func (c *Scratch) Add(key string, newAddend interface{}) (string, error)
- func (c *Scratch) Delete(key 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
- type Scratcher
Functions ¶
func GetNestedParam ¶
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 ¶
func GetNestedParamFn(keyStr, separator string, lookupFn func(key string) interface{}) (interface{}, string, map[string]interface{}, error)
func GetString ¶
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 ToLower ¶
func ToLower(m Params)
ToLower makes all the keys in the given map lower cased and will do so recursively. Notes: * This will modify the map given. * Any nested map[interface{}]interface{} will be converted to Params.
func ToStringMap ¶
func ToStringMap(in interface{}) map[string]interface{}
func ToStringMapE ¶
Types ¶
type KeyRenamer ¶
type KeyRenamer struct {
// contains filtered or unexported fields
}
KeyRenamer supports renaming of keys in a map.
func NewKeyRenamer ¶
func NewKeyRenamer(patternKeys ...string) (KeyRenamer, error)
NewKeyRenamer creates a new KeyRenamer given a list of pattern and new key value pairs.
func (KeyRenamer) Rename ¶
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 ¶
type Params map[string]interface{}
Params is a map where all keys are lower case.
func (Params) Get ¶
Get does a lower case and nested search in this map. It will return nil if none found.
type Scratch ¶
type Scratch struct {
// contains filtered or unexported fields
}
Scratch is a writable context used for stateful operations in Page/Node rendering.
func NewScratch ¶
func NewScratch() *Scratch
NewScratch returns a new instance Scratch.
func (*Scratch) Add ¶
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) Delete ¶
Delete deletes the given key.
func (*Scratch) Get ¶
Get returns a value previously set by Add or Set.
func (*Scratch) GetSortedMapValues ¶
GetSortedMapValues returns a sorted map previously filled with SetInMap.
func (*Scratch) Set ¶
Set stores a value with the given key in the Node context. This value can later be retrieved with Get.
func (*Scratch) SetInMap ¶
SetInMap stores a value to a map with the given key in the Node context. This map can later be retrieved with GetSortedMapValues.
type Scratcher ¶
type Scratcher interface { Scratch() *Scratch }
Scratcher provides a scratching service.
func NewScratcher ¶
func NewScratcher() Scratcher
NewScratcher creates a new Scratcher.
Source Files ¶
maps.go maps_get.go params.go scratch.go
- Version
- v0.60.1
- Published
- Nov 29, 2019
- Platform
- linux/amd64
- Imports
- 8 packages
- Last checked
- 7 hours ago –
Tools for package owners.