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:
meehawk
2021-05-17 19:15:33 +05:30
committed by GitHub
parent 76c95f55a5
commit abbc99d4c6
3 changed files with 37 additions and 0 deletions

View File

@@ -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`