From 5d00abdb00b86b63135012b4f095f0d7915f34c1 Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Sun, 27 Jan 2019 23:32:15 -0500 Subject: New functions conv.Keys and conv.Values Signed-off-by: Dave Henderson --- docs-src/content/functions/conv.yml | 44 +++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'docs-src') diff --git a/docs-src/content/functions/conv.yml b/docs-src/content/functions/conv.yml index 85432558..e12b510c 100644 --- a/docs-src/content/functions/conv.yml +++ b/docs-src/content/functions/conv.yml @@ -404,3 +404,47 @@ funcs: - | $ gomplate -i '{{ conv.ToStrings nil 42 true 0xF (slice 1 2 3) }}' [nil 42 true 15 [1 2 3]] + - name: conv.Keys + alias: keys + description: | + Return a list of keys in one or more maps. + + The keys will be ordered first by map position (if multiple maps are given), + then alphabetically. + + See also [`conv.Values`](#conv-values). + arguments: + - name: in... + required: true + description: the maps + examples: + - | + $ gomplate -i '{{ $map := json `{"foo": 1, "bar": 2}` -}} + {{ conv.Keys $map }}' + [bar foo] + $ gomplate -i '{{ $map1 := json `{"foo": 1, "bar": 2}` -}} + {{ $map2 := json `{"baz": 3, "qux": 4}` -}} + {{ conv.Keys $map1 $map2 }}' + [bar foo baz qux] + - name: conv.Values + alias: values + description: | + Return a list of values in one or more maps. + + The values will be ordered first by map position (if multiple maps are given), + then alphabetically by key. + + See also [`conv.Keys`](#conv-keys). + arguments: + - name: in... + required: true + description: the maps + examples: + - | + $ gomplate -i '{{ $map := json `{"foo": 1, "bar": 2}` -}} + {{ conv.Values $map }}' + [2 1] + $ gomplate -i '{{ $map1 := json `{"foo": 1, "bar": 2}` -}} + {{ $map2 := json `{"baz": 3, "qux": 4}` -}} + {{ conv.Values $map1 $map2 }}' + [2 1 3 4] -- cgit v1.2.3