Skip to content

[Rejected AI junk] indent: honor blank=False for empty first line when first=True - #2268

Closed
devtechedge wants to merge 1 commit into
pallets:mainfrom
devtechedge:fix/indent-blank-first-line
Closed

devtechedge wants to merge 1 commit into
pallets:mainfrom
devtechedge:fix/indent-blank-first-line

Conversation

@devtechedge

Copy link
Copy Markdown

Summary

indent(..., first=True) was always prefixing the indent width, even when the first line was empty and blank was left at its default False. That made empty input (and an empty first line) render as spaces instead of staying empty.

Example from #2176:

Environment().from_string("{% filter indent(4, first=True) %}{% endfilter %}").render()
# was "    ", now ""

first=True still indents a non-empty first line. With blank=True, an empty first line is still indented.

Changes

  • Only prepend indent when first=True if blank=True or the first line is non-empty
  • Regression coverage for empty filter body, empty string, and multiline empty-first-line cases
  • CHANGES.rst + versionchanged note for 3.2

fixes #2176

Test plan

  • pytest tests/test_filters.py -k indent (4 passed)
  • full tests/test_filters.py (133 passed)

When first=True and blank=False, skip indenting an empty first line
(including fully empty input) so blank keeps its meaning for the first
line as well. Fixes #2176.
@ThiefMaster ThiefMaster closed this Sep 9, 2026
@ThiefMaster ThiefMaster changed the title indent: honor blank=False for empty first line when first=True [Rejected AI junk] indent: honor blank=False for empty first line when first=True Sep 9, 2026
@davidism

davidism commented Sep 9, 2026

Copy link
Copy Markdown
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants