From 7dc282eaf95359061a7a8a2f5015786d15f40c2b Mon Sep 17 00:00:00 2001 From: meehawk <80167324+meehawk@users.noreply.github.com> Date: Mon, 17 May 2021 19:15:33 +0530 Subject: [PATCH] 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 --- content/en/functions/scratch.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/content/en/functions/scratch.md b/content/en/functions/scratch.md index 10623b2cb..f42b0ad57 100644 --- a/content/en/functions/scratch.md +++ b/content/en/functions/scratch.md @@ -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`