diff options
Diffstat (limited to 'docs/content/functions/data.md')
| -rw-r--r-- | docs/content/functions/data.md | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/docs/content/functions/data.md b/docs/content/functions/data.md index 0243b25b..dbbf45f2 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://`, `stdin://`, `http://`, `https://`, and `vault://` URLs are supported. +Currently, `file://`, `stdin://`, `http://`, `https://`, `vault://`, and `boltdb://` URLs are supported. Currently-supported formats are JSON, YAML, TOML, and CSV. @@ -53,6 +53,22 @@ $ echo 'foo' | gomplate -i '{{ include "data" }}' -d data=stdin: foo ``` +### Overriding the MIME type + +On occasion it's necessary to override the MIME type a datasource is parsed with. +To accomplish this, gomplate supports a `type` query string parameter on +datasource URLs. This can contain the same value as a standard +[HTTP Content-Type](https://tools.ietf.org/html/rfc7231#section-3.1.1.1) +header. + +For example, to force a file named `data.txt` to be parsed as a JSON document: + +```console +$ echo '{"foo": "bar"}' > /tmp/data.txt +$ gomplate -d data=file:///tmp/data.txt?type=application/json -i '{{ (ds "data").foo }}' +bar +``` + ### Usage with HTTP data ```console |
