Skip to main content
# 🦸‍♂️ Not the solution `jinja2` deserves, but the workaround it needs right now.
`jinja2_workarounds` offers an extension for jinja2 that works around a long standing issue[^1]
where `include` does not preserve correct indentation for multi-line includes. Simply add the
`jinja2_workarounds.MultiLineInclude` [extension to your environment](https://jinja.palletsprojects.com/en/3.0.x/extensions/) and use the `indent content` directive to
correctly indent your multi-line includes.

## Installation
```pip install jinja2_workarounds```


## Usage example
```jinja2
# text.j2
this
is
some
text
```

```jinja2
# example.j2
example:
{% include 'text.j2' indent content %}
```

is then rendered as

```
example:
this
is
some
text
```

compared to `jinja2`'s default `include` which would result in

```
example:
this
is
some
text
```

## Advanced features
`MultiLineInclude` is compatible with custom `block_start_string` and `block_end_string`. It also works with
the advanced features of `jinja2'`s `include` statement. The following variants are all supported and work as
expected

```jinja2
{% include 'missing.j2' ignore missing indent content %} # handle missing templates
{% include ['foo.j2', 'bar.j2'] indent content %} # multiple alternative templates
{% include 'child.j2' without context %} # include child with/without content
{%- include 'child.j2' +%} # include with custom whitespace control
```

[^1]: https://github.com/pallets/jinja/issues/178

Metadata

Release files for jinja2-workarounds 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jinja2-workarounds 0.1.0
File Size Uploaded Provenance
jinja2_workarounds-0.1.0.tar.gz 2.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for jinja2-workarounds 0.1.0
File Interpreter ABI Platform
jinja2_workarounds-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 5.7 kB

Release files / jinja2_workarounds-0.1.0.tar.gz

Download URL jinja2_workarounds-0.1.0.tar.gz
Size 2.8 kB
Tags Source
SHA-256 checksum
How to use checksums
e65457b3dab2a1601ba8b5987f03ac890c426cd40d3bb18603a8a03322a21afb
BLAKE2b-256 checksum
How to use checksums
b17658edb886a14ef80768393cd2cd704ad3a2bcdcd715417ca4831fc68f5594
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.11 CPython/3.9.8 Darwin/20.6.0

Release files / jinja2_workarounds-0.1.0-py3-none-any.whl

Download URL jinja2_workarounds-0.1.0-py3-none-any.whl
Size 2.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
04c772eeb10975ad638d960a5d4eddc35bab00d8d0ab7695d8d540646d2692bf
BLAKE2b-256 checksum
How to use checksums
a6829a4a3d0f13720269f634e927356ed6d87fb03c4263b3945a151fe177bea1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.11 CPython/3.9.8 Darwin/20.6.0

Security for jinja2-workarounds 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page