jinja icon indicating copy to clipboard operation
jinja copied to clipboard

Added linebreak option for indent filter.

Open mjeromin opened this issue 1 year ago • 7 comments

This change fixes the indent filter so that it can support any line break sequence, including line feed (LF), carriage return line feed (CRLF), and carriage return (CR), whichever newline sequence is set in the environment.

https://github.com/pallets/jinja/issues/2016

fixes #2016

👋 This is my first time contributing, please advise if an entry to CHANGES.rst should be added and which version it should be associated (e.g. 3.2.0).

mjeromin avatar Oct 02 '24 04:10 mjeromin

The issue points out that the environment already has a setting for the line ending. That should be used instead of adding a filter argument.

davidism avatar Oct 02 '24 05:10 davidism

As stated in #2016 , the changes addressed my use case. Was any search for any other instances of hardcoded use of '\n' made?

jmbraben avatar Oct 29 '24 19:10 jmbraben

Was any search for any other instances of hardcoded use of '\n' made?

I don't think so. If you (or someone else) want to look, and find other places that should use the env setting, that would be another good issue to open.

davidism avatar Oct 29 '24 19:10 davidism

There is nothing else in filters.py, the only thing in /src I'm questioning is: https://github.com/pallets/jinja/blob/ada0a9a6fc265128b46949b5144d2eaa55e6df2c/src/jinja2/compiler.py#L457 But as in the compiler.py, thinking it is not an issue.

jmbraben avatar Oct 29 '24 19:10 jmbraben

You're right, that's not an issue.

davidism avatar Oct 29 '24 20:10 davidism

@mjeromin Is there any timeline to merge this?

jmbraben avatar Nov 15 '24 19:11 jmbraben

@jmbraben We confirmed the fix in the issue #2016, we can go ahead and merge. Thanks!

mjeromin avatar Nov 15 '24 22:11 mjeromin