Skip to main content

Generates files by parsing the environment with jinja2

Project description

Render a file with jinja2 using a context built from processing environment variables.

Installation

From pip:

$ pip install env-render

Usage

To render a jinja document and collect all the environment variables with the prefix APP, enter this command:

$ env-render -p APP src_template.txt output.txt

Example

So imagine this environment:

APP_0_ENV0=a
APP_0_ENV1=b
APP_0_HOSTNAME=app_0
APP_1_ENV0=c
APP_1_ENV1=d
APP_1_HOSTNAME=app_1
APP_2_ENV0=e
APP_2_ENV1=f
APP_2_HOSTNAME=app_2

Becomes this dictionary:

{
    "apps": [
        {
            "_index": 0,
            "ENV0": "a",
            "ENV1": "b",
            "HOSTNAME": "app_0"
        },
        {
            "_index": 1,
            "ENV0": "c",
            "ENV1": "d",
            "HOSTNAME": "app_1"
        },
        {
            "_index": 2,
            "ENV0": "e",
            "ENV1": "f",
            "HOSTNAME": "app_2"
        }
    ]
}

Which can then be used like this in a file. Say an haproxy.cfg file:

listen someapp
    bind 0.0.0.0:80

    {% for app in apps %}
    server server{{ app._index }} {{ app.HOSTNAME }}:80
    {% endfor %}

This is what this library is meant to do.

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

env-render-0.1.1.tar.gz (4.4 kB view details)

Uploaded Source

File details

Details for the file env-render-0.1.1.tar.gz.

File metadata

  • Download URL: env-render-0.1.1.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for env-render-0.1.1.tar.gz
Algorithm Hash digest
SHA256 89d5baded6857a0dfb5290096a87317f4168e0b976c349e27808ac92172c7bc6
MD5 43722ad17627b74af79678c5e3e33aaa
BLAKE2b-256 268813283827f54faa4fe9d489436ba61330be4bfbe2e82b39ae2f38c3e97f65

See more details on using hashes here.

Supported by

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