From 2e972e568ff52d3c4606ce2b6350c0e764f44e03 Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Sat, 8 Sep 2018 08:45:48 -0400 Subject: Adding dict/conv.Dict function Signed-off-by: Dave Henderson --- docs-src/content/functions/conv.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'docs-src/content') diff --git a/docs-src/content/functions/conv.yml b/docs-src/content/functions/conv.yml index 4f57f311..96d0e95b 100644 --- a/docs-src/content/functions/conv.yml +++ b/docs-src/content/functions/conv.yml @@ -7,6 +7,42 @@ funcs: alias: bool - name: conv.Default alias: default + - name: conv.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 or maps with non-`string` keys, see + [`data.JSON`](../data/#data-json) or [`data.YAML`](../data/#data-yaml). + + For creating arrays, see [`conv.Slice`](#conv-slice). + arguments: + - name: in... + required: true + description: The key/value pairs + examples: + - | + $ gomplate -i '{{ conv.Dict "name" "Frank" "age" 42 | data.ToYAML }}' + age: 42 + name: Frank + $ gomplate -i '{{ dict 1 2 3 | toJSON }}' + {"1":"2","3":""} + - | + $ cat <