Skip to main content

jiren

jiren is an application that generates text from a template. The format of the template is based on jinja2.

PyPI PyPI - Python Version Python Tests codecov pre-commit.ci status

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:

$ echo "hello, {{ name }}" | jiren - -- --name=world
hello, world

An example of reading a template from a file:

$ echo "hello, {{ name }}" >template.j2
$ jiren template.j2 -- --name=world
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.

$ echo "{{ message }}, {{ name }}" | jiren --help -
... (omitted)

variables:
  --name NAME
  --message MESSAGE

Default values

You can set default values for variables for which no values was specified. This is based on the jinja2 specification.

Command:

echo "{{ message }}, {{ name | default('world') }}" | jiren - -- --message=hello

Outputs:

hello, world

Option: data

You can pass a file with variables defined structurally using the --data option.

Command:

cat <<EOF >data.yaml
greeting:
  message: hello
  name: world
EOF

echo "{{ greeting.message }}, {{ greeting.name }}" | jiren --data=data.yaml -

Outputs:

hello, world

Option: strict

If the --strict option is used with the --data option, all variables in the data file must be used in the template.

Command:

cat <<EOF >data.yaml
message: hello
invalid_key: invalid
EOF

echo "{{ message }}" | jiren --data=data.yaml --strict -

Outputs:

jiren: error: the data file contains unknown variables: invalid_key

Option: required

When using the --required option, you must specify values for all variables.

Command:

echo "{{ message }}, {{ name }}" | jiren --required - -- --message=hello

Outputs:

jiren: error: the following variables are required: name

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.7.6.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

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

jiren-0.7.6-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file jiren-0.7.6.tar.gz.

File metadata

  • Download URL: jiren-0.7.6.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for jiren-0.7.6.tar.gz
Algorithm Hash digest
SHA256 04533395e6229ef54cabb4f79d0e4594e0bb737209ee013635a96fde6759dbd8
MD5 96617d1be145f1a48dcce00bd8b69fc0
BLAKE2b-256 82334fdfae2b5a4965b4631c96eab201b1fd76bf974767521a72f5c4eb35199b

See more details on using hashes here.

File details

Details for the file jiren-0.7.6-py3-none-any.whl.

File metadata

  • Download URL: jiren-0.7.6-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for jiren-0.7.6-py3-none-any.whl
Algorithm Hash digest
SHA256 11f0438bd08500a59b931576222667f925cf9cd1dd433edcb3d005e3874fb142
MD5 9197c6da9f6927199bea19697988a097
BLAKE2b-256 f4d43887a569b0043a712e666e1974d55f41a59a5cdf2ca35741387d0d38ea58

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 Sentry Error logging StatusPage Status page