summaryrefslogtreecommitdiff
path: root/docs-src
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-src
parentdeeb86fad7864d6216c1b10f52b2ea4d31435123 (diff)
feat(coll): New coll.Set and coll.Unset functions (#2118)
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'docs-src')
-rw-r--r--docs-src/content/functions/coll.yml49
1 files changed, 49 insertions, 0 deletions
diff --git a/docs-src/content/functions/coll.yml b/docs-src/content/functions/coll.yml
index 06027130..88ff1d98 100644
--- a/docs-src/content/functions/coll.yml
+++ b/docs-src/content/functions/coll.yml
@@ -461,3 +461,52 @@ funcs:
{{ $keys := coll.Slice "foo" "baz" }}
{{ coll.Omit $keys $data }}'
map[bar:2]
+ - name: coll.Set
+ # released: v4.0.0
+ alias: set
+ description: |
+ Sets the given key to the given value in the given map.
+
+ The map is modified in place, and the modified map is returned.
+ pipeline: true
+ arguments:
+ - name: key
+ required: true
+ description: the key (string) to set
+ - name: value
+ required: true
+ description: the value to set
+ - name: map
+ required: true
+ description: the map to modify
+ examples:
+ - |
+ $ gomplate -i '{{ $data := dict "foo" 1 "bar" 2 }}
+ {{ coll.Set "baz" 3 $data }}'
+ map[bar:2 baz:3 foo:1]
+ - |
+ $ gomplate -i '{{ dict "foo" 1 | coll.Set "bar" 2 }}'
+ map[bar:2 foo:1]
+ - name: coll.Unset
+ # released: v4.0.0
+ alias: unset
+ description: |
+ 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.
+ pipeline: true
+ arguments:
+ - name: key
+ required: true
+ description: the key (string) to unset
+ - name: map
+ required: true
+ description: the map to modify
+ examples:
+ - |
+ $ gomplate -i '{{ $data := dict "foo" 1 "bar" 2 "baz" 3 }}
+ {{ coll.Unset "bar" $data }}'
+ map[baz:3 foo:1]
+ - |
+ $ gomplate -i '{{ dict "foo" 1 "bar" 2 | coll.Unset "bar" }}'
+ map[foo:1]