summaryrefslogtreecommitdiff
path: root/docs/content
diff options
context:
space:
mode:
authorDave Henderson <dhenderson@gmail.com>2024-06-16 21:17:14 -0400
committerGitHub <noreply@github.com>2024-06-17 01:17:14 +0000
commit532d68b358743ba7462bc2229d502bcfc7b8e89d (patch)
tree7cbe4bed2deb818de057a0868efc990d12bad09d /docs/content
parentdeeb86fad7864d6216c1b10f52b2ea4d31435123 (diff)
feat(coll): New coll.Set and coll.Unset functions (#2118)
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'docs/content')
-rw-r--r--docs/content/functions/coll.md75
1 files changed, 75 insertions, 0 deletions
diff --git a/docs/content/functions/coll.md b/docs/content/functions/coll.md
index 6448ac9b..a80d5a5f 100644
--- a/docs/content/functions/coll.md
+++ b/docs/content/functions/coll.md
@@ -706,3 +706,78 @@ $ gomplate -i '{{ $data := dict "foo" 1 "bar" 2 "baz" 3 }}
{{ coll.Omit $keys $data }}'
map[bar:2]
```
+
+## `coll.Set`_(unreleased)_
+**Unreleased:** _This function is in development, and not yet available in released builds of gomplate._
+
+**Alias:** `set`
+
+Sets the given key to the given value in the given map.
+
+The map is modified in place, and the modified map is returned.
+
+### Usage
+
+```
+coll.Set key value map
+```
+```
+map | coll.Set key value
+```
+
+### Arguments
+
+| name | description |
+|------|-------------|
+| `key` | _(required)_ the key (string) to set |
+| `value` | _(required)_ the value to set |
+| `map` | _(required)_ the map to modify |
+
+### Examples
+
+```console
+$ gomplate -i '{{ $data := dict "foo" 1 "bar" 2 }}
+{{ coll.Set "baz" 3 $data }}'
+map[bar:2 baz:3 foo:1]
+```
+```console
+$ gomplate -i '{{ dict "foo" 1 | coll.Set "bar" 2 }}'
+map[bar:2 foo:1]
+```
+
+## `coll.Unset`_(unreleased)_
+**Unreleased:** _This function is in development, and not yet available in released builds of gomplate._
+
+**Alias:** `unset`
+
+Deletes the element with the specified key in the given map. If there is no such element, the map is returned unchanged.
+
+The map is modified in place, and the modified map is returned.
+
+### Usage
+
+```
+coll.Unset key map
+```
+```
+map | coll.Unset key
+```
+
+### Arguments
+
+| name | description |
+|------|-------------|
+| `key` | _(required)_ the key (string) to unset |
+| `map` | _(required)_ the map to modify |
+
+### Examples
+
+```console
+$ gomplate -i '{{ $data := dict "foo" 1 "bar" 2 "baz" 3 }}
+{{ coll.Unset "bar" $data }}'
+map[baz:3 foo:1]
+```
+```console
+$ gomplate -i '{{ dict "foo" 1 "bar" 2 | coll.Unset "bar" }}'
+map[foo:1]
+```