summaryrefslogtreecommitdiff
path: root/docs/content
diff options
context:
space:
mode:
authorDave Henderson <dhenderson@gmail.com>2022-05-29 15:03:51 -0400
committerDave Henderson <dhenderson@gmail.com>2022-05-30 14:06:32 -0400
commitc0b93d7ebdfd27badbb41eb62ca0bd77b0252308 (patch)
tree2f3b3e17023f4819cf69dee8953ea44463588bae /docs/content
parent9ae9a6a5182342f775383646058807222947f483 (diff)
Support URLs for nested templates
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'docs/content')
-rw-r--r--docs/content/config.md14
-rw-r--r--docs/content/usage.md24
2 files changed, 35 insertions, 3 deletions
diff --git a/docs/content/config.md b/docs/content/config.md
index 01a21324..9e488e8a 100644
--- a/docs/content/config.md
+++ b/docs/content/config.md
@@ -406,7 +406,19 @@ suppressEmpty: true
See [`--template`/`-t`](../usage/#template-t).
-An array of template references. Can be just a path or an alias and a path:
+```yaml
+templates:
+ t:
+ url: file:///foo/bar/helloworld.tmpl
+ remote:
+ url: https://example.com/api/v1/someremotetemplate
+ header:
+ Authorization: ["Basic aGF4MHI6c3dvcmRmaXNoCg=="]
+ dir: foo/bar/
+```
+
+_(Deprecated)_ Can also be an array of template references. Can be just a path,
+or an alias and a path:
```yaml
templates:
diff --git a/docs/content/usage.md b/docs/content/usage.md
index e51181bd..1a918791 100644
--- a/docs/content/usage.md
+++ b/docs/content/usage.md
@@ -189,10 +189,30 @@ Use `--left-delim`/`--right-delim` or set `$GOMPLATE_LEFT_DELIM`/`$GOMPLATE_RIGH
### `--template`/`-t`
-Add a nested template that can be referenced by the main input template(s) with the [`template`](https://golang.org/pkg/text/template/#hdr-Actions) built-in or the functions in the [`tmpl`](../functions/tmpl/) namespace. Specify multiple times to add multiple template references.
+Add a nested template or directory of templates that can be referenced by the
+main input template(s) with the [`template`](https://golang.org/pkg/text/template/#hdr-Actions)
+built-in or the functions in the [`tmpl`](../functions/tmpl/) namespace. Specify
+multiple times to add multiple template references.
-A few different forms are valid:
+Similar to data sources, the value is a `alias=url` pair, where `alias` is the
+template name and `url` is an optionally-relative URL to the template file or
+directory. Note that currently only `file:` URLs are supported.
+
+In addition to the `alias=url` form, in certain cases the alias may be omitted,
+in which case the `url` will be used as the `alias`. When referencing a
+directory, all files in the directory will be included, available to be
+referenced as `alias/<filename>`.
+
+Some examples:
+
+- `--template foo=file:///tmp/foo.tmpl`
+ - References a file `/tmp/foo.tmpl`
+ - It will be available as a template named `foo`:
+ ```console
+ $ gomplate --template foo=file:///tmp/foo.tmpl -i 'here are the contents of the template: [ {{ template "foo" }} ]'
+ here are the contents of the template: [ hello, world! ]
+ ```
- `--template mytemplate.t`
- References a file `mytemplate.t` in the current working directory.
- It will be available as a template named `mytemplate.t`: