A CLI tool for generating files from Jinja2 templates and environment variables.
Project description
A CLI tool for generating files from Jinja2 templates and environment variables.
Examples
$ template -h
usage: template [-h] [-o OUTPUT] [filename]
A CLI tool for generating files from Jinja2 templates and environment
variables.
positional arguments:
filename Input filename
optional arguments:
-h, --help show this help message and exit
-o OUTPUT, --output OUTPUT
Output to filename
$ export name='John'
$ echo 'Hello {{ name if name is defined else 'world' }}. | template
Hello John.
$ echo '{{ USER }}' > username.j2
$ template --output username.txt username.j2
$ cat username.txt
John
Jinja filters
The following Jinja filters were added:
to_yaml
: Convert to yaml.from_yaml
: Convert from yaml.to_json
: Convert to json.from_json
: Convert from json.pprint
: Pretty print variable.combine
: Combine 2 dictionaries.to_toml
: Convert to toml.from_toml
: Convert from toml.jmespath
: Queries data using the JMESPath query language.
Example usage can be seen in tests.sh
and for specific filters in the
docstrings in template/filters.py
.
Testing
Tests require Python 2.7, Python 3.3 or later and Tox and are run by running
tox
. Also, Travis CI is used to test on multiple Python versions for
every push.
Release
Releases require Python 2.7 or Python 3.3 or later and Tox. To release a new
version bump the version in the VERSION
file and run tox -e
release
.
License
This software is licensed under the AGPL 3+ license (see the LICENSE.txt
file).
TODO
Fix test failure on Python 3.2 (https://travis-ci.org/adarnimrod/template/jobs/194581463).
Release on tagged commits to PyPI in Travis CI (https://docs.travis-ci.com/user/deployment/pypi/ and https://docs.travis-ci.com/user/encryption-keys/).
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 Distributions
Built Distribution
Hashes for template-0.4.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 027bc2b9fa7ba9470ab272e5f0e2e9e846ac781c2b5371468dc7b64c28a1c42e |
|
MD5 | c6ead02996304b0245ce8077d0d02651 |
|
BLAKE2b-256 | 5942ff58f81c49985a3652533c9de60ed6e8636b023f114cf08ebfc257c1e4d4 |