jinja2 template renderer
Project description
jiren
jiren is an application that generates text from a template. The format of the template is based on jinja2.
Read this in Japanese: 日本語
Installation
pip install jiren
Usage
Generate text
Generate text from a template using the jiren command. This command can read a template from stdin or files.
An example of reading a template from stdin:
Command:
echo "hello, {{ name }}" | jiren -- --name=world
Outputs:
hello, world
An example of reading a template from a file:
Command:
cat <<EOF >template.j2
hello, {{ name }}
EOF
jiren -i template.j2 -- --name=world
Outputs:
hello, world
In this example, the template contains a variable called name. You can set values for variables in a template using program arguments passed to the jiren command. Note that the arguments for the variables must be located after --.
If you want to know more about template format, please refer to jinja2 document ( http://jinja.pocoo.org/ ).
Variables in a template
You can use the help to check the variables defined in a template.
Command:
echo "{{ greeting }}, {{ name }}" | jiren -- --help
Outputs:
... (omitted)
variables:
--name NAME
--greeting GREETING
Default values
You can set default values for variables for which no values was specified. This is based on the jinja2 specification.
Command:
echo "{{ greeting }}, {{ name | default('world') }}" | jiren -- --greeting=hello
Outputs:
hello, world
Option: required
When using the --required option, you must specify values for all variables.
Command:
echo "{{ greeting }}, {{ name }}" | jiren --required -- --greeting=hello
Outputs:
... (omitted)
jiren: error: the following arguments are required: --name
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jiren-0.3.1.tar.gz.
File metadata
- Download URL: jiren-0.3.1.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.4 CPython/3.9.1 Linux/5.4.0-1032-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b1488e5e186dae78abdd294101dd691fe77d92061d527eec895dd627594918d
|
|
| MD5 |
217103611375bf730db742fb91d159f9
|
|
| BLAKE2b-256 |
cd911d06cd321533106d1cd4efa205412c73d1acc2f1ead2e5ccd37144695300
|
File details
Details for the file jiren-0.3.1-py3-none-any.whl.
File metadata
- Download URL: jiren-0.3.1-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.4 CPython/3.9.1 Linux/5.4.0-1032-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3a161f426881a52ab0b15b7028b707af2a39ff5ae688b9dea13b2c92964e807
|
|
| MD5 |
30cb1ee740f4a414825bd3b5cfb7cf9a
|
|
| BLAKE2b-256 |
56cb0fbed799e9f4e642794a21d901dce103d9a18cfc172621c7f5eba6f6ca8b
|