Skip to main content

CLI renderer for Jinja2

Project description

jinplate

Code style: black linting: pylint

A command line Jinja2 renderer inspired by gomplate

jinplate can read from local and remote variable files in a number of formats and use them to render a local Jinja2 template file.

jinplate uses URIs to identify how to fetch and parse Jinja2 variable files.

Installation

pip install jinplate

To install with support for the tests and filters included with ansible, use

pip install jinplate[ansible]

Usage

jinplate --help
Usage: jinplate [OPTIONS] TEMPLATE_FILE DATASOURCES...

  A command line renderer for jinja templates

  TEMPLATE_FILE is the path to a jinja template file to render

  DATASOURCES is a list of URIs to data sources supported by jinplate which
  contain the template variables. Data sources are parsed and merged into a single
  dict in the order in which they are specified.

  --jinja-ext allows specifying a comma-separated list of import paths
  containing jinja extensions. Example: --jinja-ext jinja2.ext.i18n

Options:
  --jinja-ext TEXT
  --help            Show this message and exit.

Local Vars Example

test.j2

---

key: {{ test1.key }}
arr: {{ test2.arr }}

vars.json

{
  "test1": {
    "key": "val"
  },
  "test2": {
    "arr": [1, 2, 3]
  }
}
jinplate test.j2 "file:///$(pwd)/vars.json"

---

key: val
arr: [1, 2, 3]

Remote Vars example

python -m http.server
jinplate test.j2 "http://127.0.0.1:8000/vars.json"

---

key: val
arr: [1, 2, 3]

Supported Vars File Schemes

URI Scheme Plugin Example
file jinplate.plugins.scheme.file file:////path/to/vars.yaml
http jinplate.plugins.scheme.http http://127.0.0.1:8000/vars

Supported Vars File Types

File types are determined by extension, but can also be overridden by appending +<file_type> to the datasource URI scheme, as in http+json://

File type Matching extensions Plugin Example
json .json jinplate.plugins.filetype.json http+json://127.0.0.1:8000/vars
yaml .yaml, .yml jinplate.plugins.filetype.yaml http://127.0.0.1:8000/vars.yml
file:////path/to/vars.yaml
dotenv .env jinplate.plugins.filetype.dotenv file+env:////path/to/vars

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

jinplate-0.0.6.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jinplate-0.0.6-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file jinplate-0.0.6.tar.gz.

File metadata

  • Download URL: jinplate-0.0.6.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for jinplate-0.0.6.tar.gz
Algorithm Hash digest
SHA256 eb102cdc98743cc71f2fdefed40a163320f21d3d02f9bf92ce89922a0228ab65
MD5 36a7513063a9d519ccb2c052f71ee698
BLAKE2b-256 e792f9cf80a9b51242098b7800e2bca24209fe5daa3e55a87bf4434995ef46f3

See more details on using hashes here.

File details

Details for the file jinplate-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: jinplate-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for jinplate-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 c83ce578145b6e62f4d976dfdcc8ba056f8b2bd137606f24505da50dadc4940d
MD5 36d965793632f7d446a7a2f092d734d9
BLAKE2b-256 ec4ff261ea673efe1c2bc05564e316fff2c5ded6acb95cc64a22f5ac1a6f9a52

See more details on using hashes here.

Supported by

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