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.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2cb6738bc3248f92aa88b67a06ba571065604200f4fad8ba5f0fba4bb2c4c241 |
|
MD5 | 76e559e7460f57045d15fa486cbddcf7 |
|
BLAKE2b-256 | 987af117e825b82de3234635573145261beb81e71aae03a4c1b98cfadba57bc7 |
Close
Hashes for jinja2_getenv_extension-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca44bd0f0878d95f990a37f25e4f2b469ff44ebd8ac916a6f27e034eefe6c5c5 |
|
MD5 | f689a752891e7fce51bcb7e13ee88c38 |
|
BLAKE2b-256 | f984f7d6c5dda93aeb8e2671f8b2a41175bc40aab1461bfa08648c2d3056477f |