mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-20 21:31:32 +02:00
common/maps: Add Scratch.DeleteInMap
Add Scratch.DeleteInMap method. This method works similar to Scratch.SetInMap. It takes in two string parameters, key and mapKey and deletes the value mapped to mapKey in key Closes #8504
This commit is contained in:
@@ -97,6 +97,18 @@ Takes a `key`, `mapKey` and `value` and add a map of `mapKey` and `value` to the
|
||||
{{ .Scratch.Get "greetings" }} > map[french:Bonjour english:Hello]
|
||||
```
|
||||
|
||||
#### .DeleteInMap
|
||||
Takes a `key` and `mapKey` and removes the map of `mapKey` from the given `key`.
|
||||
|
||||
```go-html-template
|
||||
{{ .Scratch.SetInMap "greetings" "english" "Hello" }}
|
||||
{{ .Scratch.SetInMap "greetings" "french" "Bonjour" }}
|
||||
----
|
||||
{{ .Scratch.DeleteInMap "greetings" "english" }}
|
||||
----
|
||||
{{ .Scratch.Get "greetings" }} > map[french:Bonjour]
|
||||
```
|
||||
|
||||
#### .GetSortedMapValues
|
||||
Returns array of values from `key` sorted by `mapKey`
|
||||
|
||||
|
Reference in New Issue
Block a user