<!-- 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": "https://mirkolenz.github.io/makejinja/",
"name": "makejinja",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.11,<4.0",
"maintainer_email": "",
"keywords": "jinja2,home-assistant,hassio,dashboard,lovelace,template,generator,cli,tool,library",
"author": "Mirko Lenz",
"author_email": "mirko@mirkolenz.com",
"download_url": "https://files.pythonhosted.org/packages/26/8f/06cdd99faccdb847e19e140785d2853a6b274545026ef970e8521c5773d1/makejinja-2.5.0.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\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Generate entire directory structures using Jinja templates with support for external data and custom plugins.",
"version": "2.5.0",
"project_urls": {
"Documentation": "https://mirkolenz.github.io/makejinja/makejinja/cli.html",
"Homepage": "https://mirkolenz.github.io/makejinja/",
"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": "9555f982a0c294e4e3daa5b828d8bfbd1c0edcea9db026fcad44e91956cbf13f",
"md5": "d0911125b0699928a985f1dd8c498440",
"sha256": "9b38633e527f1157ec7a894400f6c70b65d29a836973615a0e44fb0cb7c7fbad"
},
"downloads": -1,
"filename": "makejinja-2.5.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d0911125b0699928a985f1dd8c498440",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11,<4.0",
"size": 14210,
"upload_time": "2024-01-21T21:27:30",
"upload_time_iso_8601": "2024-01-21T21:27:30.329449Z",
"url": "https://files.pythonhosted.org/packages/95/55/f982a0c294e4e3daa5b828d8bfbd1c0edcea9db026fcad44e91956cbf13f/makejinja-2.5.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "268f06cdd99faccdb847e19e140785d2853a6b274545026ef970e8521c5773d1",
"md5": "128faf106795c917c5f0eb1cdc35cefc",
"sha256": "c12fe2479f85d98e1a7c99342cec6a11ed96e2e437413af0611cade1b107d0c8"
},
"downloads": -1,
"filename": "makejinja-2.5.0.tar.gz",
"has_sig": false,
"md5_digest": "128faf106795c917c5f0eb1cdc35cefc",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11,<4.0",
"size": 13289,
"upload_time": "2024-01-21T21:27:32",
"upload_time_iso_8601": "2024-01-21T21:27:32.388539Z",
"url": "https://files.pythonhosted.org/packages/26/8f/06cdd99faccdb847e19e140785d2853a6b274545026ef970e8521c5773d1/makejinja-2.5.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-21 21:27:32",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mirkolenz",
"github_project": "makejinja",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "makejinja"
}