{"id":4588,"library":"jinjanator","title":"Jinjanator","description":"Jinjanator is an active command-line interface (CLI) tool for rendering Jinja2 templates, offering features like multiple data source formats (INI, YAML, JSON, dotenv) and environment variable support. It originated as a fork of j2cli and jinja2-cli, both of which are no longer maintained. The library releases new versions roughly every few months, often including Python version support updates and plugin enhancements.","status":"active","version":"25.3.1","language":"en","source_language":"en","source_url":"https://github.com/kpfleming/jinjanator","tags":["jinja2","templating","cli","automation","configuration"],"install":[{"cmd":"pip install jinjanator","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Utility library for classes without boilerplate.","package":"attrs"},{"reason":"The core templating engine utilized by Jinjanator.","package":"jinja2"},{"reason":"API package for extending Jinjanator with custom formats, filters, tests, and globals.","package":"jinjanator-plugins"},{"reason":"Support for loading environment variables from .env files.","package":"python-dotenv"},{"reason":"YAML data format parsing for input files.","package":"pyyaml"},{"reason":"Backports and extensions for Python's typing module.","package":"typing-extensions"}],"imports":[{"note":"Jinjanator is primarily a CLI tool; `main` is its internal entry point. Direct programmatic use of the `jinjanator` *tool* itself is uncommon. For general Python-level templating, import `jinja2` directly.","symbol":"main","correct":"from jinjanator.cli import main"},{"note":"For programmatic templating within Python applications, you typically interact with the `Jinja2` library directly rather than through `jinjanator`'s internal API.","symbol":"Environment","correct":"from jinja2 import Environment"}],"quickstart":{"code":"import subprocess\nimport os\nimport tempfile\n\n# Create a simple Jinja2 template content\ntemplate_content = \"<data><name>{{ name }}</name><age>{{ age }}</age></data>\"\n\n# Create a temporary template file\nwith tempfile.NamedTemporaryFile(mode=\"w\", delete=False, suffix=\".j2\") as tmp_template:\n    tmp_template.write(template_content)\n    template_path = tmp_template.name\n\ntry:\n    # Set environment variables for the subprocess that runs jinjanate\n    env = os.environ.copy()\n    env[\"name\"] = \"Andrew\"\n    env[\"age\"] = \"31\"\n\n    print(f\"Rendering template: {template_path} with name={env['name']}, age={env['age']}\")\n\n    # Run jinjanate command. Both 'j2' and 'jinjanate' are valid entry points.\n    result = subprocess.run(\n        [\"jinjanate\", template_path],\n        capture_output=True,\n        text=True,\n        check=True, # Raise CalledProcessError if the command returns a non-zero exit code\n        env=env\n    )\n\n    print(\"\\n--- Rendered output ---\")\n    print(result.stdout)\n    print(\"-----------------------\")\n\nexcept subprocess.CalledProcessError as e:\n    print(f\"Error rendering template: {e}\")\n    print(f\"Stderr: {e.stderr}\")\nfinally:\n    # Clean up the temporary file\n    os.remove(template_path)\n","lang":"python","description":"This quickstart demonstrates how to use `jinjanator` via its command-line interface within a Python script. It creates a temporary Jinja2 template file, sets environment variables, and then executes the `jinjanate` command to render the template. The output is printed to the console."},"warnings":[{"fix":"Upgrade your Python environment to a version supported by your Jinjanator installation, or pin Jinjanator to an older version that supports your Python environment. Refer to the project's `pyproject.toml` or release notes for current Python compatibility.","message":"Major versions of Jinjanator frequently drop support for older Python versions and add support for newer ones. For example, version 25.3.0 removed support for Python 3.9, and 24.4.0 removed Python 3.8 support. Users must ensure their Python environment meets the `requires_python` specification for their installed Jinjanator version.","severity":"breaking","affected_versions":"24.4.0, 25.3.0 and newer"},{"fix":"When developing or using custom plugins, ensure they explicitly declare and pin their `jinjanator-plugins` dependency to prevent unexpected breakage with `jinjanator` updates. Consult `jinjanator-plugins` documentation for best practices.","message":"The `jinjanator-plugins` dependency, which underpins extensibility, explicitly recommends pinning to a specific version or a narrow 'year.release' range (e.g., '25.1.*'). This is due to potential non-backward-compatible API changes. Plugins relying on specific `jinjanator-plugins` versions may break if the core `jinjanator` library upgrades its `jinjanator-plugins` dependency or if the plugin itself is not carefully versioned.","severity":"breaking","affected_versions":"All versions that use `jinjanator-plugins`"},{"fix":"Upgrade to Jinjanator 25.2.0 or newer to benefit from the corrected behavior of the `--customize` argument, ensuring all customization functions are handled gracefully, even if not all hooks are present in the file. [cite: 25.2.0 release notes]","message":"In versions prior to 25.2.0, there was a corrected behavior for the `--customize` argument when the customization file did not contain every possible type of customization function. Users with complex or incomplete customization files on older versions might encounter unexpected behavior.","severity":"gotcha","affected_versions":"<25.2.0"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}