{"id":21081856,"url":"https://github.com/avielyo10/jinja2-tools","last_synced_at":"2025-05-16T09:31:14.337Z","repository":{"id":45572769,"uuid":"323847922","full_name":"Avielyo10/jinja2-tools","owner":"Avielyo10","description":"Use Jinja2 templates via cli","archived":false,"fork":false,"pushed_at":"2024-03-06T18:13:24.000Z","size":52,"stargazers_count":5,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-28T18:45:58.839Z","etag":null,"topics":["ansible","ansible-template","cli","jinja2","jinja2-cli","jinja2-templates","jinja2-tools"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/jinja2-tools/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Avielyo10.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-23T08:38:12.000Z","updated_at":"2024-09-19T09:35:55.000Z","dependencies_parsed_at":"2024-11-19T20:11:30.209Z","dependency_job_id":"49302348-3b45-4c81-b48b-42d8606fb3ed","html_url":"https://github.com/Avielyo10/jinja2-tools","commit_stats":{"total_commits":44,"total_committers":2,"mean_commits":22.0,"dds":0.09090909090909094,"last_synced_commit":"7d41656bb95e8a7693f6f1ca46827472201c8c7a"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Avielyo10%2Fjinja2-tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Avielyo10%2Fjinja2-tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Avielyo10%2Fjinja2-tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Avielyo10%2Fjinja2-tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Avielyo10","download_url":"https://codeload.github.com/Avielyo10/jinja2-tools/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254504766,"owners_count":22082083,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","ansible-template","cli","jinja2","jinja2-cli","jinja2-templates","jinja2-tools"],"created_at":"2024-11-19T20:11:15.803Z","updated_at":"2025-05-16T09:31:13.799Z","avatar_url":"https://github.com/Avielyo10.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Jinja2 tools\n\nUse Jinja2 templates via cli\n\n## Install\n\n```\n$ pip install jinja2-tools\n```\n\n## Usage\n\n```\nUsage: jinja render [OPTIONS]\nOptions:\n  -d, --data TEXT          PATH to YAML or JSON data file, URL or '-' for\n                           stdin.\n\n  -t, --template TEXT      PATH to directory or to any file that uses Jinja,\n                           URL or '-' for stdin.\n\n  -v, --verbose\n  -tb, --no-trim-blocks    Disable trim blocks.\n  -lb, --no-lstrip-blocks  Disable lstrip blocks.\n  -o, --output PATH        PATH for output, stdout by default.\n  -e, --extra-var TEXT     key value pair separated by '='. 'value' will be\n                           treated as JSON or as a string in case of JSON\n                           decoding error. This will take precedence over\n                           'data'.\n\n  --help                   Show this message and exit.\n```\n\n## Whitespace Control\n\n`trim_blocks` and `lstrip_blocks` are used by default, to disable them use `-tb` or `-lb` respectively.\n\n## Examples\n\n* Use path from the filesystem for data \u0026 template:\n  ```\n  ➜ jinja render -d examples/data/data.yaml -t examples/templates/template.yaml\n  (1)\n  ip access-list extended al-hq-in\n  (2)\n      (3)    remark Allow traffic from hq to local office\n      (4)(2)\n      (3)    permit 10.0.0.0/22 10.100.0.0/24\n      (5)(6)\n  (7)\n\n  # All ACLs have been generated\n  ```\n\n* Use stdin for data \u0026 URL for template, also disable trim blocks \u0026 lstrip blocks:\n  ```\n  ➜ jinja render -d - -t https://raw.githubusercontent.com/Avielyo10/jinja2-tools/master/examples/templates/template.yaml -lb -tb \u003c examples/data/data.yaml\n  (1)\n  ip access-list extended al-hq-in\n    (2)\n      (3)\n      remark Allow traffic from hq to local office\n      (4)\n    (2)\n      (3)\n      permit 10.0.0.0/22 10.100.0.0/24\n      (5)\n    (6)\n  (7)\n\n  # All ACLs have been generated\n  ```\n\n* Verbose:\n  ```\n  ➜ jinja render -d examples/data/data.yaml -t examples/templates/template.yaml -v     \n  ---------- [Data] ----------\n  {\n    \"access_lists\": {\n      \"al-hq-in\": [\n        {\n          \"action\": \"remark\",\n          \"text\": \"Allow traffic from hq to local office\"\n        },\n        {\n          \"action\": \"permit\",\n          \"src\": \"10.0.0.0/22\",\n          \"dst\": \"10.100.0.0/24\"\n        }\n      ]\n    }\n  }\n\n  ---------- [Template] ----------\n  {% for acl, acl_lines in access_lists.items() %}(1)\n  ip access-list extended {{ acl }}\n    {% for line in acl_lines %}(2)\n      (3){% if line.action == \"remark\" %}\n      remark {{ line.text }}\n      (4){% elif line.action == \"permit\" %}\n      permit {{ line.src }} {{ line.dst }}\n      (5){% endif %}\n    {% endfor %}(6)\n  {% endfor %}(7)\n\n  # All ACLs have been generated\n\n  (1)\n  ip access-list extended al-hq-in\n  (2)\n      (3)    remark Allow traffic from hq to local office\n      (4)(2)\n      (3)    permit 10.0.0.0/22 10.100.0.0/24\n      (5)(6)\n  (7)\n\n  # All ACLs have been generated\n  ```\n\n* Pass the data using multiple extra vars:\n  ```\n  ➜ jinja render -t examples/templates/template.yaml \\\n  -e access_lists='{\"al-hq-in\": [{\"action\": \"remark\", \"text\": \"Allow traffic from hq to local office\"}, {\"action\": \"permit\", \"src\": \"10.0.0.0/22\", \"dst\": \"10.100.0.0/24\"}]}' \\\n  -e message=world \\\n  -v\n  ---------- [ExtraVars] ----------\n  {\n    \"access_lists\": {\n      \"al-hq-in\": [\n        {\n          \"action\": \"remark\",\n          \"text\": \"Allow traffic from hq to local office\"\n        },\n        {\n          \"action\": \"permit\",\n          \"src\": \"10.0.0.0/22\",\n          \"dst\": \"10.100.0.0/24\"\n        }\n      ]\n    },\n    \"message\": \"world\"\n  } \n\n  ---------- [Template] ----------\n  {% for acl, acl_lines in access_lists.items() %}(1)\n  ip access-list extended {{ acl }}\n    {% for line in acl_lines %}(2)\n      (3){% if line.action == \"remark\" %}\n      remark {{ line.text }}\n      (4){% elif line.action == \"permit\" %}\n      permit {{ line.src }} {{ line.dst }}\n      (5){% endif %}\n    {% endfor %}(6)\n  {% endfor %}(7)\n  hello {{ message }}!\n  # All ACLs have been generated \n\n  (1)\n  ip access-list extended al-hq-in\n  (2)\n      (3)    remark Allow traffic from hq to local office\n      (4)(2)\n      (3)    permit 10.0.0.0/22 10.100.0.0/24\n      (5)(6)\n  (7)\n  hello world!\n  # All ACLs have been generated\n  ```\n\n* Use directory option\n  ```\n  ➜ jinja render -d examples/data/data.yaml -t examples/ -o test/\n  ➜ tree test/\n  test/\n  ├── config\n  │   ├── example.ini\n  │   └── example.properties\n  ├── data\n  │   ├── data.json\n  │   └── data.yaml\n  └── templates\n      ├── lookup.yaml\n      └── template.yaml\n\n  3 directories, 6 files\n  ➜ cat test/templates/template.yaml\n  (1)\n  ip access-list extended al-hq-in\n  (2)\n      (3)    remark Allow traffic from hq to local office\n      (4)(2)\n      (3)    permit 10.0.0.0/22 10.100.0.0/24\n      (5)(6)\n  (7)\n  hello jinja!\n  # All ACLs have been generated\n  ```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favielyo10%2Fjinja2-tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Favielyo10%2Fjinja2-tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favielyo10%2Fjinja2-tools/lists"}