a jinja2 extension to access to system environment variables
Project description
What is it ?
This is a jinja2 extension to access to system environment variables. It is usefull if you have dynamically generated variable names.
Syntax
The syntax is {{ 'ENV_VAR'|getenv }}
to access to the ENV_VAR
environment
variable. Don't forget the quotes around ENV_VAR
!
If you want to provide a default value to avoid an exception if the corresponding
environment variable does not exist, you can use the following syntax:
{{ 'ENV_VAR'|getenv('default_value') }}
.
Examples
from jinja2 import Template, Environment
# We load the extension in a jinja2 Environment
env = Environment(extensions=["jinja2_getenv_extension.GetenvExtension"])
# For the example, we use a template from a simple string
template = env.from_string("the value of HOME environment variable is: "
"{{ 'HOME'|getenv }}")
result = template.render()
# [...]
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for jinja2_getenv_extension-0.0.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 838eb299adaf7333cff7890429c06fac32ab672890e0a22452c40146bf6b52a2 |
|
MD5 | ed648bacfb814a93561bd00bb4270feb |
|
BLAKE2b-256 | 7e1f65f270f8af05aa9c70d56d3bb9040d3fe4287f5e7139feb48a403f0472bb |
Close
Hashes for jinja2_getenv_extension-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9cc6a2470729d875e11cce0865ed72143fbc85daa50f190657ca30e42a234e93 |
|
MD5 | 91e7c67cdf1e3375f0c860bddad68839 |
|
BLAKE2b-256 | cc2c910052d58d37501a189dbf8af1a7f17c952a397d4b2896364ec3fb1526d9 |