Skip to main content

Generate entire directory structures using Jinja templates with support for external data and custom plugins

Project description

makejinja

makejinja logo

PyPI | Docker | Docs | Example | Jinja reference

Generate entire directory structures using Jinja templates with support for external data and custom plugins.

makejinja demonstration


makejinja can be used to automatically generate files from Jinja templates. It is conceptually similar to Ansible templates 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 popular use case is generating config files for Home Assistant: Using the same Jinja language that Home Assistant's built-in templates use, you can greatly simplify your configuration management. makejinja's custom delimiter support prevents conflicts with Home Assistant's own template syntax, while file-specific data loading enables modular dashboard and automation generation. Our comprehensive Home Assistant example demonstrates dashboard generation with custom plugins, multiple data sources, and advanced template organization.

Key Features

  • Multi-Source Data Integration: Load variables from YAML, TOML, and Python files, with support for file-specific data sources and runtime variable injection.
  • Custom Template Delimiters: Configure Jinja delimiters (e.g., <% %> instead of {{ }}) to avoid conflicts with target file formats like Home Assistant, Kubernetes, or Terraform.
  • Flexible Directory Processing: Process multiple input directories with complex nested structures, preserving hierarchy while applying powerful template transformations.
  • Extensible Plugin System: Create custom plugins with filters, functions, and path filtering logic for specialized requirements.
  • Production-Ready: Comprehensive CLI interface, configuration file support, and Python library API for seamless workflow integration.

Use Cases

  • Configuration Management: Generate environment-specific configs (dev/staging/prod) from shared templates with different data sources.
  • Home Assistant Dashboards: Create complex dashboards and automations using Jinja syntax without conflicts. See our complete example.
  • Infrastructure as Code: Generate Kubernetes manifests, Terraform modules, or Docker Compose files with consistent patterns across environments.
  • Web Development: Generate HTML pages, CSS files, or JavaScript configs from data sources for static sites or multi-tenant applications.
  • Database Schemas: Create SQL migration scripts, database configurations, or ORM models based on structured schema definitions.
  • Network Configuration: Generate router configs, firewall rules, or network device settings from centralized network topology data.
  • Monitoring & Alerting: Create Grafana dashboards, Prometheus rules, or alerting configurations from service inventories.
  • Documentation & CI/CD: Create project docs, API specifications, or pipeline definitions from structured data sources.

Installation

The tool is written in Python and can be installed via uv, nix, and docker. It can be used as a CLI tool or as a Python library.

UV

makejinja is available on PyPI and can be installed via uv:

uv tool install makejinja
makejinja -i ./input -o ./output

Nix

makejinja is packaged in nixpkgs. To use the most recent version, you can run it via nix run:

nix run github:mirkolenz/makejinja -- -i ./input -o ./output

Alternatively, you can add this repository as an input to your flake and use makejinja.packages.${system}.default.

Docker

We automatically publish an image to the GitHub Container Registry. To use it, mount a directory to the container and pass the options as the command:

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 contains a detailed description of all options and can also be accessed via makejinja --help.

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 Distribution

makejinja-2.8.0.tar.gz (18.3 kB view details)

Uploaded Source

Built Distribution

makejinja-2.8.0-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file makejinja-2.8.0.tar.gz.

File metadata

  • Download URL: makejinja-2.8.0.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for makejinja-2.8.0.tar.gz
Algorithm Hash digest
SHA256 48a2c98ccdf8be14785cca83053cc835ba4797c0745c5145e81d6f954e153b05
MD5 683427f4c0abcd7246f4ac8b1262c43a
BLAKE2b-256 63383fa7cc56fed3e5934a0afa325a78d239afde3bd3a9443ae40c12a5dd55f7

See more details on using hashes here.

Provenance

The following attestation bundles were made for makejinja-2.8.0.tar.gz:

Publisher: release.yml on mirkolenz/makejinja

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file makejinja-2.8.0-py3-none-any.whl.

File metadata

  • Download URL: makejinja-2.8.0-py3-none-any.whl
  • Upload date:
  • Size: 15.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for makejinja-2.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6a10df647ff0f2fc8a0db3d75162f5bcfe5b378a3ce49722efc0e3c9c5bbf8b3
MD5 c174a96e91387bf966c03a4453bcaab7
BLAKE2b-256 1ee9de1734e10f8b29d36bc354f25da03ce9782c82e3f737d8433204890366bf

See more details on using hashes here.

Provenance

The following attestation bundles were made for makejinja-2.8.0-py3-none-any.whl:

Publisher: release.yml on mirkolenz/makejinja

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page