a jinja2 extension to access to system environment variables
Project description
jinja2_getenv_extension
Status (master branch)
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()
# [...]
Contributing guide
See CONTRIBUTING.md file.
Code of Conduct
See CODE_OF_CONDUCT.md file.
Sponsors
(If you are officially paid to work on MetWork Framework, please contact us to add your company logo here!)
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
Hashes for jinja2_getenv_extension-1.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | df55bdaba2938340e6341eea9d13817e98940d7eb1a76ab9b2eff064f0b76264 |
|
MD5 | 38b24d7dcca73e3b2e6757c98c86241d |
|
BLAKE2b-256 | 1cb25923d18de44203788bd1bf8dbc5ebad64217ebcebc0b1d6bfc5b0717ac9a |
Hashes for jinja2_getenv_extension-1.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ffb480f5dcfe0410c8ad60747b2b186d40328f2d3ad6b30a222cddc4d832bc1e |
|
MD5 | 3e206515fe327e236eeafb68ddbf6624 |
|
BLAKE2b-256 | 1a14e2a5bf03e1c628aa294e070196023e1530148c37c83d61bb60b88bd31226 |