<!-- markdownlint-disable MD033 MD041 -->
<h2><p align="center">makejinja</p></h2>
<p align="center">
<img width="256px" alt="makejinja logo" src="https://raw.githubusercontent.com/mirkolenz/makejinja/main/assets/logo.png" />
</p>
<p align="center">
<a href="https://pypi.org/project/makejinja/">PyPI</a> |
<a href="https://github.com/users/mirkolenz/packages/container/package/makejinja">Docker</a> |
<a href="https://mirkolenz.github.io/makejinja">Docs</a> |
<a href="https://github.com/mirkolenz/makejinja/tree/main/tests/data">Example</a> |
<a href="https://jinja.palletsprojects.com/en/3.1.x/templates">Jinja reference</a>
</p>
<p align="center">
Generate entire directory structures using Jinja templates with support for external data and custom plugins.
</p>
---
# makejinja
makejinja can be used to automatically generate files from [Jinja templates](https://jinja.palletsprojects.com/en/3.1.x/templates).
It is conceptually similar to [Ansible templates](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/template_module.html) since both are built on top of Jinja.
However, makejinja is a standalone tool that can be used without Ansible and offers some advanced features like custom plugins.
A use case for this tool is generating config files for [Home Assistant](https://www.home-assistant.io/):
Using the same language that the built-in templates use, you can greatly simplify your configuration.
An [example for Home Assistant](https://github.com/mirkolenz/makejinja/tree/main/tests/data) can be found in the tests directory.
## Highlights
- Recursively render nested directories containing template files to a common output directory.
- Load data files containing variables to use in your Jinja templates from YAML, TOML, and Python files.
- Write custom [plugins](https://mirkolenz.github.io/makejinja/makejinja/plugin.html#Plugin) to extend the functionality of makejinja.
- Adjust all Jinja options (e.g., whitespace behavior and delimiters) to your needs via CLI flags or a config file.
## Installation
The tool is written in Python and can be installed via pip, nix, and docker.
It can be used as a CLI tool or as a Python library.
### PIP
makejinja is available on [PyPI](https://pypi.org/project/makejinja/) and can be installed via `pip`:
```shell
pip install makejinja
makejinja -i ./input -o ./output
```
### Nix
If you use the `nix` package manager, you can add this repository as an input to your flake and use `makejinja.packages.${system}.default` or apply the overlay `makejinja.overlays.default`.
You can also run it directly as follows:
```shell
nix run github:mirkolenz/makejinja -- -i ./input -o ./output
```
### Docker
We automatically publish an image to the [GitHub Container Registry](https://ghcr.io/mirkolenz/makejinja).
To use it, mount a directory to the container and pass the options as the command:
```shell
docker run --rm -v $(pwd)/data:/data ghcr.io/mirkolenz/makejinja:latest -i /data/input -o /data/output
```
## Usage in Terminal / Command Line
In its default configuration, makejinja searches the input directory recursively for files ending in `.jinja`.
It then renders these files and writes them to the output directory, preserving the directory structure.
Our [documentation](https://mirkolenz.github.io/makejinja/makejinja/cli.html) contains a detailed description of all options and can also be accessed via `makejinja --help`.
Raw data
{
"_id": null,
"home_page": null,
"name": "makejinja",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": null,
"keywords": "jinja2, home-assistant, hassio, dashboard, lovelace, template, generator, cli, tool, library",
"author": null,
"author_email": "Mirko Lenz <mirko@mirkolenz.com>",
"download_url": "https://files.pythonhosted.org/packages/64/f7/32e25933f1a91c34457d0ebab7410e93cd17600bb5820ca16d13cb2b886d/makejinja-2.7.1.tar.gz",
"platform": null,
"description": "<!-- markdownlint-disable MD033 MD041 -->\n<h2><p align=\"center\">makejinja</p></h2>\n<p align=\"center\">\n <img width=\"256px\" alt=\"makejinja logo\" src=\"https://raw.githubusercontent.com/mirkolenz/makejinja/main/assets/logo.png\" />\n</p>\n<p align=\"center\">\n <a href=\"https://pypi.org/project/makejinja/\">PyPI</a> |\n <a href=\"https://github.com/users/mirkolenz/packages/container/package/makejinja\">Docker</a> |\n <a href=\"https://mirkolenz.github.io/makejinja\">Docs</a> |\n <a href=\"https://github.com/mirkolenz/makejinja/tree/main/tests/data\">Example</a> |\n <a href=\"https://jinja.palletsprojects.com/en/3.1.x/templates\">Jinja reference</a>\n</p>\n<p align=\"center\">\n Generate entire directory structures using Jinja templates with support for external data and custom plugins.\n</p>\n\n---\n\n# makejinja\n\nmakejinja can be used to automatically generate files from [Jinja templates](https://jinja.palletsprojects.com/en/3.1.x/templates).\nIt is conceptually similar to [Ansible templates](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/template_module.html) since both are built on top of Jinja.\nHowever, makejinja is a standalone tool that can be used without Ansible and offers some advanced features like custom plugins.\nA use case for this tool is generating config files for [Home Assistant](https://www.home-assistant.io/):\nUsing the same language that the built-in templates use, you can greatly simplify your configuration.\nAn [example for Home Assistant](https://github.com/mirkolenz/makejinja/tree/main/tests/data) can be found in the tests directory.\n\n## Highlights\n\n- Recursively render nested directories containing template files to a common output directory.\n- Load data files containing variables to use in your Jinja templates from YAML, TOML, and Python files.\n- Write custom [plugins](https://mirkolenz.github.io/makejinja/makejinja/plugin.html#Plugin) to extend the functionality of makejinja.\n- Adjust all Jinja options (e.g., whitespace behavior and delimiters) to your needs via CLI flags or a config file.\n\n## Installation\n\nThe tool is written in Python and can be installed via pip, nix, and docker.\nIt can be used as a CLI tool or as a Python library.\n\n### PIP\n\nmakejinja is available on [PyPI](https://pypi.org/project/makejinja/) and can be installed via `pip`:\n\n```shell\npip install makejinja\nmakejinja -i ./input -o ./output\n```\n\n### Nix\n\nIf you use the `nix` package manager, you can add this repository as an input to your flake and use `makejinja.packages.${system}.default` or apply the overlay `makejinja.overlays.default`.\nYou can also run it directly as follows:\n\n```shell\nnix run github:mirkolenz/makejinja -- -i ./input -o ./output\n```\n\n### Docker\n\nWe automatically publish an image to the [GitHub Container Registry](https://ghcr.io/mirkolenz/makejinja).\nTo use it, mount a directory to the container and pass the options as the command:\n\n```shell\ndocker run --rm -v $(pwd)/data:/data ghcr.io/mirkolenz/makejinja:latest -i /data/input -o /data/output\n```\n\n## Usage in Terminal / Command Line\n\nIn its default configuration, makejinja searches the input directory recursively for files ending in `.jinja`.\nIt then renders these files and writes them to the output directory, preserving the directory structure.\nOur [documentation](https://mirkolenz.github.io/makejinja/makejinja/cli.html) contains a detailed description of all options and can also be accessed via `makejinja --help`.\n",
"bugtrack_url": null,
"license": null,
"summary": "Generate entire directory structures using Jinja templates with support for external data and custom plugins",
"version": "2.7.1",
"project_urls": {
"Changelog": "https://github.com/mirkolenz/makejinja/releases",
"Documentation": "https://mirkolenz.github.io/makejinja/makejinja/cli.html",
"Homepage": "https://mirkolenz.github.io/makejinja/",
"Issues": "https://github.com/mirkolenz/makejinja/issues",
"Repository": "https://github.com/mirkolenz/makejinja"
},
"split_keywords": [
"jinja2",
" home-assistant",
" hassio",
" dashboard",
" lovelace",
" template",
" generator",
" cli",
" tool",
" library"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a413e3b30cd37f207d23fca5830bdf878dc2d56bbad4c746868141e646ac21b1",
"md5": "7d8ccf919d1d4e208641117901b4debd",
"sha256": "84d470d0c15fa9fa2b25744d90dd2ea806d06fd2657f91a3597349d3b43689ce"
},
"downloads": -1,
"filename": "makejinja-2.7.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7d8ccf919d1d4e208641117901b4debd",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 14681,
"upload_time": "2024-11-17T10:42:57",
"upload_time_iso_8601": "2024-11-17T10:42:57.177942Z",
"url": "https://files.pythonhosted.org/packages/a4/13/e3b30cd37f207d23fca5830bdf878dc2d56bbad4c746868141e646ac21b1/makejinja-2.7.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "64f732e25933f1a91c34457d0ebab7410e93cd17600bb5820ca16d13cb2b886d",
"md5": "a81ef06df4ac104563a74ab9e480ceb7",
"sha256": "5b8d25cb88667b5dfdb2f732d429ff3e5c9411099c35d83dd75a062a45390b64"
},
"downloads": -1,
"filename": "makejinja-2.7.1.tar.gz",
"has_sig": false,
"md5_digest": "a81ef06df4ac104563a74ab9e480ceb7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 15513,
"upload_time": "2024-11-17T10:42:58",
"upload_time_iso_8601": "2024-11-17T10:42:58.702032Z",
"url": "https://files.pythonhosted.org/packages/64/f7/32e25933f1a91c34457d0ebab7410e93cd17600bb5820ca16d13cb2b886d/makejinja-2.7.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-17 10:42:58",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mirkolenz",
"github_project": "makejinja",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "makejinja"
}