From 400af7d6edb5022bf6dd88887d0af17b2c3cade0 Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Mon, 28 Jan 2019 22:18:00 -0500 Subject: New collections (coll) namespace, plus new functions Signed-off-by: Dave Henderson --- docs-src/content/functions/coll.yml | 197 ++++++++++++++++++++++++++++ docs-src/content/functions/conv.yml | 50 +------ docs-src/content/functions/func_doc.md.tmpl | 3 +- 3 files changed, 203 insertions(+), 47 deletions(-) create mode 100644 docs-src/content/functions/coll.yml (limited to 'docs-src') diff --git a/docs-src/content/functions/coll.yml b/docs-src/content/functions/coll.yml new file mode 100644 index 00000000..c4d61dce --- /dev/null +++ b/docs-src/content/functions/coll.yml @@ -0,0 +1,197 @@ +ns: coll +title: collection functions +preamble: | + These functions help manipulate and query collections of data, like lists (slices, or arrays) and maps (dictionaries). + + #### Implementation Note + For the functions that return an array, a Go `[]interface{}` is returned, regardless of whether or not the + input was a different type. +funcs: + - name: coll.Dict + alias: dict + description: | + Dict is a convenience function that creates a map with string keys. + Provide arguments as key/value pairs. If an odd number of arguments + is provided, the last is used as the key, and an empty string is + set as the value. + + All keys are converted to strings. + + This function is equivalent to [Sprig's `dict`](http://masterminds.github.io/sprig/dicts.html#dict) + function, as used in [Helm templates](https://docs.helm.sh/chart_template_guide#template-functions-and-pipelines). + + For creating more complex maps, see [`data.JSON`](../data/#data-json) or [`data.YAML`](../data/#data-yaml). + + For creating arrays, see [`coll.Slice`](#coll-slice). + arguments: + - name: in... + required: true + description: The key/value pairs + examples: + - | + $ gomplate -i '{{ coll.Dict "name" "Frank" "age" 42 | data.ToYAML }}' + age: 42 + name: Frank + $ gomplate -i '{{ dict 1 2 3 | toJSON }}' + {"1":2,"3":""} + - | + $ cat <