{"id":15580489,"url":"https://github.com/toabctl/j2gen","last_synced_at":"2025-03-15T02:17:03.900Z","repository":{"id":62572034,"uuid":"211037292","full_name":"toabctl/j2gen","owner":"toabctl","description":"Tool to render Jinja2 templates with mutliple input YAML data sources","archived":false,"fork":false,"pushed_at":"2019-09-30T08:25:38.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-08T05:46:28.612Z","etag":null,"topics":["cli","jinja2","templating"],"latest_commit_sha":null,"homepage":"","language":"Python","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/toabctl.png","metadata":{"files":{"readme":"README.rst","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}},"created_at":"2019-09-26T08:19:12.000Z","updated_at":"2019-09-30T08:23:49.000Z","dependencies_parsed_at":"2022-11-03T17:00:59.726Z","dependency_job_id":null,"html_url":"https://github.com/toabctl/j2gen","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toabctl%2Fj2gen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toabctl%2Fj2gen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toabctl%2Fj2gen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toabctl%2Fj2gen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/toabctl","download_url":"https://codeload.github.com/toabctl/j2gen/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243672487,"owners_count":20328768,"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":["cli","jinja2","templating"],"created_at":"2024-10-02T19:28:20.523Z","updated_at":"2025-03-15T02:17:03.859Z","avatar_url":"https://github.com/toabctl.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"j2gen\n=====\nTool to render `Jinja2`_ templates with mutliple input `YAML`_ data sources.\n\nFeatures\n--------\n- Render files as `Jinja2`_ templates (usually ending with .j2)\n- Use `YAML`_ as data source for templating\n- Multiple YAML data sources are allowed to overlay sources\n\nUsage\n-----\nLet's show some examples what `j2gen`_ is good for.\n\nSimple rendering\n++++++++++++++++\nA `test.j2` template::\n\n  Hello {{ variable }} !\n\nA `test.yaml` file containing the data::\n\n  ---\n  variable: world\n\nWill render to::\n\n  $ j2gen generate test.j2 test.yaml\n  Hello world !\n\nBy default, `j2gen`_ will write its output to stdout. Use the `--output`\n(or `-o`) flag to write to a file::\n\n  $ j2gen generate -o output test.j2 test.yaml\n  $ cat output\n  Hello world !\n\nRendering with multiple sources\n+++++++++++++++++++++++++++++++\nThere are cases where you want a common data source (eg. `common.yaml`)\nbut need to overwrite parts of the common source (eg. with `special.yaml`):\n\n`common.yaml` looks like::\n\n  container:\n    base: openSUSE-Leap-15.1\n    name: memcached container for openSUSE\n    description:\n      short: memcached container\n      long: memcached container for openSUSE\n\n`special.yaml` looks like::\n\n  container:\n    base: SLES15SP1\n    name: memcached container for SLES15SP1\n    description:\n      long: memcached container for SUSE Linux Enterprise Server 15 SP1\n\n`template.j2` looks like::\n\n  Base      : {{ container.base }}\n  Name      : {{ container.name }}\n  Desc short: {{ container.description.short }}\n  Desc long : {{ container.description.long }}\n\nThis results in::\n\n  $ j2gen generate template.j2 common.yaml special.yaml\n  Base      : SLES15SP1\n  Name      : memcached container for SLES15SP1\n  Desc short: memcached container\n  Desc long : memcached container for SUSE Linux Enterprise Server 15 SP1\n\nNote here that `container.description.short` is taken from the `common.yaml`\ninput while all the other variables are overwritten with the values from\n`special.yaml`. So dict/hash like structures in the YAML data sources are deep\nmerged.\nAnother important part is the order of the `input` files when calling\n`j2gen generate`. The last source wins (in this case `special.yaml`).\n\nContributing\n------------\nI'm happy about every contribution like bugfixes, filling issues, improving\ndocumentation or whatever.\n\n- For bugs: https://github.com/toabctl/j2gen/issues\n- For changes: https://github.com/toabctl/j2gen/pulls\n\nRunning tests\n+++++++++++++\n\nThe testsuite can be executed locally with::\n\n  $ tox\n\n.. _Jinja2: https://jinja.palletsprojects.com/\n.. _YAML: https://yaml.org/\n.. _j2gen: https://github.com/toabctl/j2gen\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoabctl%2Fj2gen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftoabctl%2Fj2gen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoabctl%2Fj2gen/lists"}