From 01b39ee0955b59abdf1895b18435f1731226fcac Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Sat, 18 Nov 2017 09:33:49 -0500 Subject: Adding support for stdin: scheme for datasources Signed-off-by: Dave Henderson --- docs/content/functions/data.md | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'docs/content/functions/data.md') diff --git a/docs/content/functions/data.md b/docs/content/functions/data.md index 18bb4f7c..0243b25b 100644 --- a/docs/content/functions/data.md +++ b/docs/content/functions/data.md @@ -11,7 +11,7 @@ A collection of functions that retrieve, parse, and convert structured data. Parses a given datasource (provided by the [`--datasource/-d`](#--datasource-d) argument). -Currently, `file://`, `http://`, `https://`, and `vault://` URLs are supported. +Currently, `file://`, `stdin://`, `http://`, `https://`, and `vault://` URLs are supported. Currently-supported formats are JSON, YAML, TOML, and CSV. @@ -34,6 +34,25 @@ $ gomplate -d person.json < input.tmpl Hello Dave ``` +### Providing datasources on standard input (`stdin`) + +Normally `stdin` is used as the input for the template, but it can also be used +to provide datasources. To do this, specify a URL with the `stdin:` scheme: + +```console +$ echo 'foo: bar' | gomplate -i '{{(ds "data").foo}}' -d data=stdin:///foo.yaml +bar +``` + +Note that the URL must have a file name with a supported extension in order for +the input to be correctly parsed. If no parsing is required (i.e. if the data +is being included verbatim with the include function), just `stdin:` is enough: + +```console +$ echo 'foo' | gomplate -i '{{ include "data" }}' -d data=stdin: +foo +``` + ### Usage with HTTP data ```console -- cgit v1.2.3