Skip to main content

Jinja2 Templating with JSON files

Project description

jjtemplate

Jinja2 Templating with JSON files

Example

example.txt.jinja:

Hello, {{ name }}.

example.json:

{
    "name": "world"
}

You run:

$ jjtemplate -o result.txt example.txt.jinja example.json

Then you get result.txt:

Hello, world.

Install

$ pip install jjtemplate

Usage

usage: jjtemplate [-h] [-i IMPORT_NAME] [-o OUTPUT] template_file [json_files ...]

positional arguments:
  template_file         Jinja2 template file
  json_files            JSON files loaded to the context (top-level object must
                        be a dictionary)

optional arguments:
  -h, --help            show this help message and exit
  -i IMPORT_NAME, --import IMPORT_NAME
                        import Python module to the context (can be put
                        multiple times)
  -o OUTPUT, --output OUTPUT
                        output file name

Installed jjtemplate command runs main function of jjtemplate.py, which is the sole entire content of the module.

You can copy jjtemplate.py and add it to your project freely. See the License section bellow.

References

License

jjtemplate is marked with CC0 1.0. To view a copy of this license, visit <https://creativecommons.org/publicdomain/zero/1.0/>.

(In other words, public domain.)

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

jjtemplate-0.9.0.tar.gz (6.0 kB view hashes)

Uploaded Source

Built Distribution

jjtemplate-0.9.0-py3-none-any.whl (6.5 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