Variables & Expressions in Jinja2
Inject values into the template.
Variables Inside Templates
Every variable available to your play is also available in the template. Just wrap its name in {{ }} to print the value. 🌟
server_name {{ domain }};
worker_processes {{ cpu_count }};Accessing Dictionary Keys
For a dictionary variable, reach a key with dot or bracket notation. Both db.host and db['host'] return the same value.
host = {{ db.host }}
port = {{ db['port'] }}All lessons in this course
- The template Module & .j2 Files
- Variables & Expressions in Jinja2
- Loops & if Blocks in Templates
- Filters: default, join & upper