razon
1
Hi, I want to delete some keys from a dict, is there any function for this?
{{ $m := dict "foo" "bar" "fizz" "buzz" }}
Remove the fizz
as below.
{{ dict "foo" "bar" }}
EDITED
The map/dict comes from the configuration, I wish to transform it before passing it to partials, for compatibility.
1 Like
This is a bit clumsy, but…
{{ $m := dict "foo" "bar" "fizz" "buzz" }}
{{ $ls := newScratch }}
{{ $ls.Set "cfg" $m }}
{{ $ls.DeleteInMap "cfg" "fizz" }}
{{ $ls.Values.cfg }} --> map[foo:bar]
2 Likes
system
Closed
4
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.