Skip to main content

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

Metadata

Release files for jinplate 0.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jinplate 0.0.7
File Size Uploaded
jinplate-0.0.7.tar.gz 9.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jinplate 0.0.7
File Interpreter ABI Platform
jinplate-0.0.7-py3-none-any.whl Python 3 none any Details

Total release size: 19.3 kB

Release files / jinplate-0.0.7.tar.gz

Download URL jinplate-0.0.7.tar.gz
Size 9.1 kB
Tags Source
SHA-256 checksum
How to use checksums
964755be93a4add6ef742c8392a2733002d793f6b9da5e222f9106afa640fbde
BLAKE2b-256 checksum
How to use checksums
0291c3047d0a9f262608578a0f14ceea576faa74a19372a16c5bcedea532356f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.4

Release files / jinplate-0.0.7-py3-none-any.whl

Download URL jinplate-0.0.7-py3-none-any.whl
Size 10.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
97d7753ca59de6a9671adb7185556745174167d34ff571ec6e4ed67b786511a4
BLAKE2b-256 checksum
How to use checksums
76241853f843d64d1db83b4eaf986a3afa65d573a6cf502f0b3f3d9edc5b66a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.4

Release history Release notifications | RSS feed

This release

0.0.7 This release

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page