{"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":"python","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,"search_vec":"'activ':5 'autom':70 'cli':10,41,69 'command':7 'command-lin':6 'configur':71 'data':20 'dotenv':26 'enhanc':66 'environ':28 'everi':55 'featur':17 'fork':35 'format':22 'includ':59 'ini':23 'interfac':9 'j2cli':37 'jinja2':14,40,67 'jinja2-cli':39 'jinjan':1,2 'json':25 'librari':50 'like':18 'line':8 'longer':47 'maintain':48 'month':57 'multipl':19 'new':52 'offer':16 'often':58 'origin':32 'plugin':65 'python':60 'releas':51 'render':13 'rough':54 'sourc':21 'support':30,62 'templat':15,68 'tool':11 'updat':63 'variabl':29 'version':53,61 'yaml':24","created_at":"2026-04-12T13:59:04.350681+00:00","updated_at":"2026-04-16T15:52:43.058760+00:00","problems":[{"fix":"Ensure the template file exists and that the path provided to the `jinjanate` command is correct, including any relative or absolute paths. For example, if 'my_template.j2' is in the current directory, use `jinjanate my_template.j2`.","cause":"The specified Jinja2 template file could not be found by Jinjanator. This often means the file path is incorrect or the file does not exist at the expected location.","error":"jinja2.exceptions.TemplateNotFound: <template_name>"},{"fix":"Provide the missing variable in a data file (e.g., `data.yaml`) and pass it to jinjanator (`jinjanate template.j2 data.yaml`), or set it as an environment variable. Alternatively, use the `--undefined` option with `jinjanate` to allow templates to use undefined variables without raising an error.","cause":"A variable was referenced in the Jinja2 template but was not provided through any of the specified data sources (INI, YAML, JSON, dotenv files, or environment variables).","error":"UndefinedError: '<variable_name>' is undefined"},{"fix":"Install Jinjanator using pip: `pip install jinjanator`. If it's already installed, ensure your system's PATH includes the directory where Python's `bin` or `Scripts` directory (containing the `jinjanate` executable) is located.","cause":"The `jinjanator` command-line tool is either not installed on your system or the directory where it's installed is not included in your system's PATH environment variable.","error":"jinjanator: command not found"},{"fix":"Review your template file for unmatched Jinja2 block tags. Ensure every `{% if %}`, `{% for %}`, etc., has a corresponding `{% endif %}`, `{% endfor %}`. The error message usually indicates the line number where the issue was detected.","cause":"The Jinja2 template contains a syntax error where an opening block tag (like `{% if %}` or `{% for %}`) is not properly closed with its corresponding end tag (e.g., `{% endif %}`, `{% endfor %}`).","error":"jinja2.exceptions.TemplateSyntaxError: Unexpected end of template"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"25.3.1","cli_name":"jinjanator","cli_version":"sh: 1: jinjanator: not found","type":"library","homepage":null,"github":"https://github.com/kpfleming/jinjanator","docs":null,"changelog":null,"pypi":"https://pypi.org/project/jinjanator/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops","data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-30","next_check":"2026-07-28","install_tag":null}}