{"id":16410161,"url":"https://github.com/stereobutter/jinja2_workarounds","last_synced_at":"2025-03-23T06:31:02.955Z","repository":{"id":48241186,"uuid":"469684926","full_name":"stereobutter/jinja2_workarounds","owner":"stereobutter","description":"A jinja2 extension for includes with correct indentation","archived":false,"fork":false,"pushed_at":"2022-10-31T08:04:31.000Z","size":14,"stargazers_count":11,"open_issues_count":4,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-18T18:21:28.770Z","etag":null,"topics":["jinja2","jinja2-extension"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stereobutter.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}},"created_at":"2022-03-14T10:30:36.000Z","updated_at":"2024-10-09T14:55:01.000Z","dependencies_parsed_at":"2022-08-24T19:41:37.336Z","dependency_job_id":null,"html_url":"https://github.com/stereobutter/jinja2_workarounds","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/stereobutter%2Fjinja2_workarounds","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stereobutter%2Fjinja2_workarounds/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stereobutter%2Fjinja2_workarounds/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stereobutter%2Fjinja2_workarounds/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stereobutter","download_url":"https://codeload.github.com/stereobutter/jinja2_workarounds/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245066496,"owners_count":20555402,"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":["jinja2","jinja2-extension"],"created_at":"2024-10-11T06:23:22.042Z","updated_at":"2025-03-23T06:31:02.600Z","avatar_url":"https://github.com/stereobutter.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🦸‍♂️ Not the solution `jinja2` deserves, but the workaround it needs right now.\n`jinja2_workarounds` offers an extension for jinja2 that works around a long standing issue[^1]\nwhere `include` does not preserve correct indentation for multi-line includes. Simply add the\n`jinja2_workarounds.MultiLineInclude` [extension to your environment](https://jinja.palletsprojects.com/en/3.0.x/extensions/) and use the `indent content` directive to\ncorrectly indent your multi-line includes.\n\n## Installation\n```pip install jinja2_workarounds```\n\n\n## Usage example\n```jinja2\n# text.j2\nthis\nis \nsome \ntext\n```\n\n```jinja2\n# example.j2\nexample:\n    {% include 'text.j2' indent content %}\n```\n\nis then rendered as \n\n```\nexample:\n    this\n    is \n    some \n    text\n```\n\ncompared to `jinja2`'s default `include` which would result in \n\n```\nexample:\n    this\nis \nsome \ntext\n```\n\n## Advanced features\n`MultiLineInclude` is compatible with custom `block_start_string` and `block_end_string`. It also works with \nthe advanced features of `jinja2'`s `include` statement. The following variants are all supported and work as\nexpected\n\n```jinja2\n{% include 'missing.j2' ignore missing indent content %}  # handle missing templates\n{% include ['foo.j2', 'bar.j2'] indent content %}  # multiple alternative templates\n{% include 'child.j2' without context %}  # include child with/without content\n{%- include 'child.j2' +%}  # include with custom whitespace control\n```\n\n[^1]: https://github.com/pallets/jinja/issues/178","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstereobutter%2Fjinja2_workarounds","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstereobutter%2Fjinja2_workarounds","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstereobutter%2Fjinja2_workarounds/lists"}