Skip to main content

a jinja2 extension to access to system environment variables

Project description

jinja2_getenv_extension

Status (master branch)

GitHub CI Maintenance

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!)

logo

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

jinja2_getenv_extension-1.0.3.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

jinja2_getenv_extension-1.0.3-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file jinja2_getenv_extension-1.0.3.tar.gz.

File metadata

  • Download URL: jinja2_getenv_extension-1.0.3.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for jinja2_getenv_extension-1.0.3.tar.gz
Algorithm Hash digest
SHA256 8e26223f1e85203d889bd3607210e9db785bacce9493fc60db2dbdeb05f3b5a7
MD5 4f1789b33132e90a7021aa65be395a23
BLAKE2b-256 32fe636df2b49329351466b1203a12b69fc94e06aa9028c064cd2f1a85ea0661

See more details on using hashes here.

File details

Details for the file jinja2_getenv_extension-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for jinja2_getenv_extension-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a3fbe24ba9c330de430c34b4bc36425bb7171e7d5016977ade4fc479d683aaa3
MD5 7591f43baa11a7edb20a216c415b73a7
BLAKE2b-256 345c38c9356e3955fbad403e86ce9c9d1e1159ffc4173b898f2e8f6b7a3829cb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page