Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add example how to set a var from file include #1439

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/templating.md
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,16 @@ an `include` is _not_ a pre-processor that pulls the included template code
into the including template before rendering; instead, it fires off a separate
render of the included template, and the results of that render are included.

Set var from file
You can also create a var from a file's content. For example a .json file, which you can then stringify using dump.
```jinja
{% set fileAsVar %}
{% include 'example.json' %}
{% endset %}

{{- fileAsVar | dump -}}
```

### import

`import` loads a different template and allows you to access its exported
Expand Down