Skip to main content

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.

PyPI PyPI - Python Version Build Status codecov

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 --var.name=world

Output:

hello, world

An example of reading a template from a file:

Command:

cat <<EOF >template.j2
hello, {{ name }}
EOF

jiren template.j2 --var.name=world

Output:

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 program arguments must be prefixed with --var..

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 "hello, {{ name }}" | jiren --help

Output:

usage: jiren [-h] [--var.name VAR.NAME] [template]

Generate text from a template

positional arguments:
  template             Template file path. If omitted, read a template from
                       stdin.

optional arguments:
  -h, --help           show this help message and exit

variables:
  --var.name VAR.NAME

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

jiren-0.2.0.tar.gz (3.6 kB view hashes)

Uploaded Source

Built Distribution

jiren-0.2.0-py3-none-any.whl (4.1 kB view hashes)

Uploaded Python 3

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