diff options
| author | Dave Henderson <dhenderson@gmail.com> | 2020-01-15 10:57:28 -0500 |
|---|---|---|
| committer | Dave Henderson <dhenderson@gmail.com> | 2020-01-15 10:57:28 -0500 |
| commit | 539f8e3b5d1ebfc7b57ec42f979fc6989c6d625f (patch) | |
| tree | 7b16d753a263233afa7d4cbd1f4edca1658f848c /docs | |
| parent | debb10ccd605e56703c7688602a067cdd2ecf709 (diff) | |
Documenting the initial context ($) variable
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/content/syntax.md | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/docs/content/syntax.md b/docs/content/syntax.md index 9fe49b33..c7995217 100644 --- a/docs/content/syntax.md +++ b/docs/content/syntax.md @@ -253,6 +253,20 @@ the default context from data sources with the [`--context`/`c`](../usage/#conte flag. The special context item [`.Env`](#env) is available for referencing the system's environment variables. +_Note:_ The initial context (`.`) is always available as the variable `$`, +so the initial context is always available, even when shadowed with `range` +or `with` blocks: + +``` +$ echo '{"bar":"baz"}' | gomplate -c .=stdin:///in.json -i 'context is: {{ . }} +{{ with "foo" }}now context is {{ . }} +but the original context is still {{ $ }} +{{ end }}' +context is: map[bar:baz] +now context is foo +but the original context is still map[bar:baz] +``` + ## Nested templates Gomplate supports nested templates, using Go's `template` action. These can be |
