diff options
| author | Dave Henderson <dhenderson@gmail.com> | 2017-06-04 11:51:54 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-06-04 11:51:54 -0400 |
| commit | 710012faef0ab91cbe09c164c85415d65a14a4f0 (patch) | |
| tree | 81e37b512e321518911ba92997a9c4bc78e547f2 /docs | |
| parent | f55b1d6844279aedfc3745258d961854f39c161e (diff) | |
| parent | 29a5bff02022cd9f99be2d3cf7c179a8e78ff6b7 (diff) | |
Merge pull request #153 from hairyhenderson/include-func-142
Add include function
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/content/functions.md | 45 | ||||
| -rw-r--r-- | docs/content/usage.md | 2 |
2 files changed, 46 insertions, 1 deletions
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` |
