Skip to content

Commit

Permalink
Merge pull request #720 from hairyhenderson/document-init-context-var…
Browse files Browse the repository at this point in the history
…iable

Documenting the initial context ($) variable
  • Loading branch information
Dave Henderson authored and GitHub committed Jan 15, 2020
2 parents debb10c + 539f8e3 commit 42bfed3
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions docs/content/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 42bfed3

Please sign in to comment.