Skip to content
Snippets Groups Projects
Select Git revision
  • db5a9ead6b0f100b733651aad3f7b8f4829b2a8f
  • master default
  • netaddr
  • ft/in-place
  • ft/run
  • v0.7.6
  • v0.7.5
  • v0.7.4
  • v0.7.3
  • v0.7.2
  • v0.7.1
  • v0.7.0
  • v0.6.6
  • v0.6.5
  • v0.6.4
  • v0.6.3
  • v0.6.2
  • v0.6.1
  • v0.6.0
  • v0.5.1
  • v0.5.0
  • v0.4.8
  • v0.4.7
  • v0.4.6
  • v0.4.4
25 results

template

Template

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.

Example usage can be seen in tests.sh.

License

This software is licensed under the AGPL 3+ license (see the LICENSE.txt file).

Author

Nimrod Adar, contact me or visit my website. Patches are welcome via git send-email. The repository is located at: https://www.shore.co.il/git/.