Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chaudum/j2y
A Jinja2 Template CLI
https://github.com/chaudum/j2y
cli hcl jinja2 json python3 yaml
Last synced: 3 months ago
JSON representation
A Jinja2 Template CLI
- Host: GitHub
- URL: https://github.com/chaudum/j2y
- Owner: chaudum
- License: apache-2.0
- Created: 2018-07-20T20:51:31.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-11-12T12:59:14.000Z (over 4 years ago)
- Last Synced: 2024-11-16T14:36:50.231Z (3 months ago)
- Topics: cli, hcl, jinja2, json, python3, yaml
- Language: Python
- Size: 43.9 KB
- Stars: 3
- Watchers: 4
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGES.rst
- License: LICENSE
Awesome Lists containing this project
README
==================
j2y - A Jinja2 CLI
==================.. image:: https://travis-ci.org/chaudum/j2y.svg?branch=master
:target: https://travis-ci.org/chaudum/j2y
:alt: Travis CI.. image:: https://badge.fury.io/py/j2y.svg
:target: http://badge.fury.io/py/j2y
:alt: Python Package Index.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/ambv/black
:alt: Code Style: Black|
Render Jinja2 templates on the command line using a YAML_, JSON_ or HCL_ file
as input for the render context.Installation
============``j2y`` is installed using ``pip``::
$ pip install j2y
.. Note::
The name of this Python package is ``j2y``, but it will be renamed to
``j2-cli`` with the next major release.Alternatively you can install directly from Github master branch::
$ pip install git+https://github.com/chaudum/j2y.git@master
Usage
=====By default, the ``j2cli`` command takes a YAML_ file as input::
$ j2cli template.j2 < values.yaml
Alternatively you can use JSON_ or HCL_ as input format::
$ j2cli template.j2 -f json < values.json
$ j2cli template.j2 -f hcl < values.hclIt's also possible to provide multiple input files::
$ j2cli template.j2 --context v1.yaml --context v2.yaml
Run ``j2cli -h`` to see all available options.
Template Variables
------------------Additionally to the variables provided by the input file, ``j2cli`` also
provides built-in default variables. These variables are::meta.date:
Type: ``datetime``Value: Current UTC datetime object
:meta.platform:
Type: ``dict``Value: Output of ``platform.uname()``
:env:
Type: ``dict``Value: All environment variables (output of ``os.environ``).
Local Development
=================Bootstrapping
-------------Create a virtualenv_ and install the package as develop egg::
$ python -m venv env
$ source env/bin/activate
(env) $ pip install -e .Tests
-----At the moment there are very simple test cases only. Test are written as
Python doctests and run using pytest_::(env) $ pip install -e ".[test]"
(env) $ pytestPytest additionally runs the black_ linter and mypy_ static type checker.
Documentation
.............The tests located in the ``docs/`` folder can also be built into HTML using
Sphinx_::(env) $ sphinx-build -E -W docs/ _build/
.. _YAML: http://yaml.org/spec/
.. _JSON: https://www.json.org/
.. _HCL: https://github.com/hashicorp/hcl
.. _virtualenv: https://docs.python.org/3/tutorial/venv.html
.. _pytest: https://docs.pytest.org/en/latest/
.. _black: https://github.com/ambv/black
.. _mypy: https://github.com/python/mypy
.. _Sphinx: http://www.sphinx-doc.org/en/master/