Skip to content

Fix ignore_blocks with non-zero indentation#1525

Open
tdryer wants to merge 1 commit intodjlint:masterfrom
tdryer:ignore_blocks_indented
Open

Fix ignore_blocks with non-zero indentation#1525
tdryer wants to merge 1 commit intodjlint:masterfrom
tdryer:ignore_blocks_indented

Conversation

@tdryer
Copy link

@tdryer tdryer commented Dec 31, 2025

The ignore_blocks option skips indentation of content inside ignored template block tags. This works by skipping indentation when a block begins. However, it does not skip un-indentation when a block ends, causing unexpected results when a block has a non-zero indentation level.

Expected:

<p>
    {% raw %}
    test
    {% endraw %}
</p>

Actual:

<p>
    {% raw %}
    test
{% endraw %}
</p>

Fix this by modifying the template_unindent pattern to exclude tags that are in ignore_blocks via a negative lookahead.

The `ignore_blocks` option skips indentation of content inside ignored
template block tags. This works by skipping indentation when a block
begins. However, it does not skip un-indentation when a block ends,
causing unexpected results when a block has a non-zero indentation
level.

Expected:

    <p>
        {% raw %}
        test
        {% endraw %}
    </p>

Actual:

    <p>
        {% raw %}
        test
    {% endraw %}
    </p>

Fix this by modifying the `template_unindent` pattern to exclude tags
that are in `ignore_blocks` via a negative lookahead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant