Skip to content

Commit c753854

Browse files
committed
Document environ() and get_context() template globals
Closes #128
1 parent 3d0bc2d commit c753854

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

docs/cli.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,25 @@ options:
4444
- Use `--section` to select a top-level key from the input data.
4545
- Use `-I` to add directories to the template search path. This allows templates
4646
to include/import from those directories. Can be specified multiple times.
47+
48+
## Template globals
49+
50+
### `environ(key)`
51+
Access environment variables:
52+
```jinja
53+
{{ environ("HOME") }}
54+
{{ environ("USER") }}
55+
```
56+
57+
Returns `None` if the variable is not set. With `--strict`, raises an error
58+
for missing variables.
59+
60+
### `get_context()`
61+
Access the root data context. Useful for iterating over all input data:
62+
```jinja
63+
{{ get_context() | length }} entries
64+
65+
{% for key, value in get_context().items() %}
66+
{{ key }}: {{ value }}
67+
{% endfor %}
68+
```

0 commit comments

Comments
 (0)