{"id":20178416,"url":"https://github.com/nvtkaszpir/python-json-via-jinja2-render","last_synced_at":"2025-04-10T04:36:00.149Z","repository":{"id":146355957,"uuid":"334529068","full_name":"nvtkaszpir/python-json-via-jinja2-render","owner":"nvtkaszpir","description":"Get json input, pass it via Jinja2 template and render it. Examples focused on how to get html output for AWS ECR scans, wagoodman/dive, skopeo and others.","archived":false,"fork":false,"pushed_at":"2023-12-10T23:07:01.000Z","size":318,"stargazers_count":4,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-24T05:51:44.936Z","etag":null,"topics":["aws-ecr","aws-ecr-tools","dive","jinja2","jinja2-docker","json","python","skopeo"],"latest_commit_sha":null,"homepage":"","language":"Jinja","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nvtkaszpir.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":"2021-01-30T22:57:42.000Z","updated_at":"2024-08-12T07:45:32.000Z","dependencies_parsed_at":"2023-12-11T00:23:08.233Z","dependency_job_id":"37c8d776-f3af-45cc-8119-503e9e7f0cd8","html_url":"https://github.com/nvtkaszpir/python-json-via-jinja2-render","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nvtkaszpir%2Fpython-json-via-jinja2-render","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nvtkaszpir%2Fpython-json-via-jinja2-render/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nvtkaszpir%2Fpython-json-via-jinja2-render/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nvtkaszpir%2Fpython-json-via-jinja2-render/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nvtkaszpir","download_url":"https://codeload.github.com/nvtkaszpir/python-json-via-jinja2-render/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248158692,"owners_count":21057188,"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":["aws-ecr","aws-ecr-tools","dive","jinja2","jinja2-docker","json","python","skopeo"],"created_at":"2024-11-14T02:20:48.427Z","updated_at":"2025-04-10T04:36:00.108Z","avatar_url":"https://github.com/nvtkaszpir.png","language":"Jinja","funding_links":[],"categories":[],"sub_categories":[],"readme":"# About\n\nVery simple script to get json input, pass it via Jinja2 template to get the output.\n\nWhy? Sometimes I got some simple json file and I want to process it into\nsomething easier to read, for example text file or html.\n\nOther tools usually do too much already, like extra connecting to internet idk why...\n\n# Known limitations\n\n* not providing pip package, I'm too lazy and this is too simple to package it anyway.... or docker, yeaaaaaaahhh ;)\n* template used is **TOTALLY** dependent on json file used as input, see examples\n\n# Requirements\n\n* pretty sure it requires python, possibly may work on python 2.x but never tested\n* requires Jinja2\n\n# Usage\n\n```bash\n\nrender.py --help\n\n```\n\n# Examples\n\n* Just see `test.sh` for exact usage.\n* See `test_extra.sh` for more complex examples, also see at the bottom some intereting use cases.\n* For results see `examples/` and `'templates/' directory for input/output and template files.\n\n| Name | Input | Template | Output |\n| ---- | ----- | -------- | ------ |\n| [wagoodman/dive](https://github.com/wagoodman/dive) HTML | [input](examples/dive.json) | [template](templates/dive_html.j2) | [output](https://nvtkaszpir.github.io/python-json-via-jinja2-render/examples/dive_html.html) |\n| [wagoodman/dive](https://github.com/wagoodman/dive) plain text | [input](examples/dive.json) | [template](templates/dive_plaintext.j2) | [output](https://nvtkaszpir.github.io/python-json-via-jinja2-render/examples/dive_plaintext.txt) |\n| AWS ECR security scan CSV | [input](examples/aws_ecr_scan_result.json) | [template](templates/aws_ecr_scan_result_csv.j2) | [output](https://nvtkaszpir.github.io/python-json-via-jinja2-render/examples/aws_ecr_scan_result_csv.csv) |\n| AWS ECR security scan CSV for failed scan | [input](examples/aws_ecr_scan_result_failed.json) | [template](templates/aws_ecr_scan_result_csv.j2) | [output](https://nvtkaszpir.github.io/python-json-via-jinja2-render/examples/aws_ecr_scan_result_csv_failed.csv) |\n| AWS ECR security scan HTML | [input](examples/aws_ecr_scan_result.json) | [template](templates/aws_ecr_scan_result_html.j2) | [output](https://nvtkaszpir.github.io/python-json-via-jinja2-render/examples/aws_ecr_scan_result_html.html) |\n| AWS ECR security scan HTML for failed scan | [input](examples/aws_ecr_scan_result_failed.json) | [template](templates/aws_ecr_scan_result_html.j2) | [output](https://nvtkaszpir.github.io/python-json-via-jinja2-render/examples/aws_ecr_scan_result_html_failed.html) |\n| AWS ECR security scan plaintext long | [input](examples/aws_ecr_scan_result.json) | [template](templates/aws_ecr_scan_result_plaintext_long.j2) | [output](https://nvtkaszpir.github.io/python-json-via-jinja2-render/examples/aws_ecr_scan_result_plaintext_long.txt) |\n| AWS ECR security scan plaintext long for failed scan | [input](examples/aws_ecr_scan_result_failed.json) | [template](templates/aws_ecr_scan_result_plaintext_long.j2) | [output](https://nvtkaszpir.github.io/python-json-via-jinja2-render/examples/aws_ecr_scan_result_plaintext_long_failed.txt) |\n| AWS ECR security scan plaintext short | [input](examples/aws_ecr_scan_result.json) | [template](templates/aws_ecr_scan_result_plaintext_short.j2) | [output](https://nvtkaszpir.github.io/python-json-via-jinja2-render/examples/aws_ecr_scan_result_plaintext_short.txt) |\n| AWS ECR security scan plaintext short for failed scan | [input](examples/aws_ecr_scan_result_failed.json) | [template](templates/aws_ecr_scan_result_plaintext_short.j2) | [output](https://nvtkaszpir.github.io/python-json-via-jinja2-render/examples/aws_ecr_scan_result_plaintext_short_failed.txt) |\n| docker inspect plain text to simulate YAML cause we can! | [input](examples/docker_inspect.json) | [template](templates/docker_inspect_plaintext.j2) | [output](https://nvtkaszpir.github.io/python-json-via-jinja2-render/examples/docker_inspect_plaintext.yaml) |\n| skopeo stdout plaintext as MarkDown | [input](examples/skopeo_stdout.json) | [template](templates/skopeo_markdown.j2) | [output](https://nvtkaszpir.github.io/python-json-via-jinja2-render/examples/skopeo_markdown.md) |\n\n# Docker\n\n```bash\ncat examples/aws_ecr_scan_result.json \\\n| docker run -v $(pwd)/templates/:/app/templates:ro \\\n  -i quay.io/kaszpir/python-json-via-jinja2-render \\\n  -t templates/aws_ecr_scan_result_html.j2 \\\n\u003e output.html\n```\n\nor with stdin/stdout:\n\n```bash\ndocker run \\\n    -v \"$(pwd)/templates/:/app/templates:ro\" \\\n    -i quay.io/kaszpir/python-json-via-jinja2-render \\\n        -t templates/aws_ecr_scan_result_html.j2 \\\n        \u003cexamples/aws_ecr_scan_result.json \\\n        \u003eoutput.html\n```\n\n# Running in container with custom templates\n\n* Create `my_template` dir with desired template\n* write `my_template/custom.j2` file which is tailored to your json input files\n* Run command to get output to stdout:\n\n```bash\ncat examples/aws_ecr_scan_result.json \\\n| docker run -v $(pwd)/my_template/:/app/templates:ro \\\n  -i quay.io/kaszpir/python-json-via-jinja2-render \\\n  -t templates/custom.j2 \\\n\u003eoutput.html\n\n```\n\n# Testing\n\n* Run under linux\n* install [yq](https://github.com/mikefarah/yq)\n* install docker\n* run `./test.sh`\n* see generated files, commit and make PR\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnvtkaszpir%2Fpython-json-via-jinja2-render","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnvtkaszpir%2Fpython-json-via-jinja2-render","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnvtkaszpir%2Fpython-json-via-jinja2-render/lists"}