Skip to content

AI junk#2200

Closed
mmustafasenoglu wants to merge 2 commits into
pallets:mainfrom
mmustafasenoglu:fix-indent-first-empty
Closed

AI junk#2200
mmustafasenoglu wants to merge 2 commits into
pallets:mainfrom
mmustafasenoglu:fix-indent-first-empty

Conversation

@mmustafasenoglu

Copy link
Copy Markdown

What this PR does

Fixes #2176

When the indent filter is called with first=True and blank=False (the default), an empty first line was incorrectly indented.

Environment().from_string("{% filter indent(4, first=True) %}{% endfilter %}").render()
# Expected: ""
# Actual: "    "

Fix

In do_indent(), the first=True branch now checks if the result is non-empty (or if blank=True) before adding indentation:

if first:
    if blank or rv:
        rv = indention + rv

This ensures blank=False takes precedence over first=True for empty lines.

Test

Added test_indent_first_empty_no_blank to verify empty strings are not indented when first=True and blank=False.

Mustafa Senoglu and others added 2 commits June 28, 2026 21:55
When the indent filter is called with first=True and blank=False (the
default), an empty first line was incorrectly indented. The blank=False
flag should take precedence, skipping indentation for empty lines.

Fixes #2176
@davidism davidism closed this Jun 29, 2026
@davidism davidism changed the title fix: don't indent empty first line with first=True blank=False AI junk Jun 29, 2026
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.

indent filter ignores blank=False when first=True on first line

2 participants