diff options
| author | Dave Henderson <dhenderson@gmail.com> | 2019-02-16 00:00:28 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-02-16 00:00:28 -0500 |
| commit | ffb7d693baa8f95df96484e9b1a9c6267be066cf (patch) | |
| tree | 7408c5892fad19dd0b09ce63c8481254ab22873e /docs | |
| parent | 4a88a3ed4c2880994975cd7ae5323c066507983a (diff) | |
| parent | 8d9ab1cffb4d0e5b0a7c70a01ad6c142952362a0 (diff) | |
Merge pull request #492 from hairyhenderson/tmpl-exec-func-444-485
New tmpl.Exec function
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/content/functions/tmpl.md | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/docs/content/functions/tmpl.md b/docs/content/functions/tmpl.md index 64a0bf64..f6da5f4d 100644 --- a/docs/content/functions/tmpl.md +++ b/docs/content/functions/tmpl.md @@ -7,6 +7,39 @@ menu: Functions for defining or executing templates. +## `tmpl.Exec` + +Execute (render) the named template. This is equivalent to using the [`template`](https://golang.org/pkg/text/template/#hdr-Actions) action, except the result is returned as a string. + +This allows for post-processing of templates. + +### Usage +```go +tmpl.Exec name [context] +``` + +```go +context | tmpl.Exec name +``` + +### Arguments + +| name | description | +|------|-------------| +| `name` | _(required)_ The template's name. | +| `context` | _(optional)_ The context to use. | + +### Examples + +```console +$ gomplate -i '{{define "T1"}}hello, world!{{end}}{{ tmpl.Exec "T1" | strings.ToUpper }}' +HELLO, WORLD! +``` +```console +$ gomplate -i '{{define "T1"}}hello, {{.}}{{end}}{{ tmpl.Exec "T1" "world!" | strings.Title }}' +Hello, World! +``` + ## `tmpl.Inline` **Alias:** `tpl` |
