From 29a5bff02022cd9f99be2d3cf7c179a8e78ff6b7 Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Sun, 4 Jun 2017 11:32:40 -0400 Subject: Add include function Signed-off-by: Dave Henderson --- docs/content/functions.md | 45 +++++++++++++++++++++++++++++++++++++++++++++ docs/content/usage.md | 2 +- 2 files changed, 46 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/content/functions.md b/docs/content/functions.md index 73d4a3bd..c8962146 100644 --- a/docs/content/functions.md +++ b/docs/content/functions.md @@ -704,6 +704,51 @@ no worries Alias to [`datasource`](#datasource) +## `include` + +Includes the content of a given datasource (provided by the [`--datasource/-d`](../usage/#datasource-d) argument). + +This is similar to [`datasource`](#datasource), +except that the data is not parsed. + +### Usage + +```go +include alias [subpath] +``` + +### Arguments + +| name | description | +|--------|-------| +| `alias` | the datasource alias, as provided by [`--datasource/-d`](../usage/#datasource-d) | +| `subpath` | _(optional)_ the subpath to use, if supported by the datasource | + +### Examples + +_`person.json`:_ +```json +{ "name": "Dave" } +``` + +_`input.tmpl`:_ +```go +{ + "people": [ + {{ include "person" }} + ] +} +``` + +```console +$ gomplate -d person.json -f input.tmpl +{ + "people": [ + { "name": "Dave" } + ] +} +``` + ## `ec2meta` Queries AWS [EC2 Instance Metadata](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html) for information. This only retrieves data in the `meta-data` path -- for data in the `dynamic` path use `ec2dynamic`. diff --git a/docs/content/usage.md b/docs/content/usage.md index 2296a7b8..a0b665a5 100644 --- a/docs/content/usage.md +++ b/docs/content/usage.md @@ -44,7 +44,7 @@ gomplate --input-dir=templates --output-dir=config --datasource config=config.ya ## `--datasource`/`-d` -Add a data source in `name=URL` form. Specify multiple times to add multiple sources. The data can then be used by the [`datasource`](#datasource) function. +Add a data source in `name=URL` form. Specify multiple times to add multiple sources. The data can then be used by the [`datasource`](../functions/#datasource) and [`include`](../functions/#include) functions. A few different forms are valid: - `mydata=file:///tmp/my/file.json` -- cgit v1.2.3