-
-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] [Formatter] #566
Comments
|
@nrnvgh I'm thinking what you need to do is set the max line length to 0 to force everything to wrap. Here's a pic from the demo https://djlint.com/demo/: Does that come how you need? |
Thanks for the quick response. The problem with your proposed solution is that the lines which reads...
...is brought back to the start of the line; the rendered YAML needs to be:
...but with
Similarly (again, with
...to this:
Which has both incorrectly tweaked indentation levels between |
ah I see, the leading space is not preserved on template syntax. That might be the best fix for this case - changing djlint to also keep indentation on lines that start w/ a template tag... if that is possible. I'll have to check out the code closely on this one :) |
@nrnvgh sorry for the delay on this. I should have an update out soon that will treat you should be able to use a config like {
"profile": "jinja",
"preserve_leading_space": true
} |
## [1.19.17](v1.19.16...v1.19.17) (2023-04-05) ### Bug Fixes * **blocktrans:** allowed closing transblocks to be indented if they have a leading space ([d667273](d667273)) * **custom tags:** fixed issue where end tag for custom block was not de-indented ([fb8bf5e](fb8bf5e)), closes [#572](#572) * **ignored code:** fixed formatting of ignore code inside django comment blocks ([120460d](120460d)), closes [#569](#569) * **linter:** linter will now ignore {% raw %} {% endraw %} blocks ([2a6865e](2a6865e)), closes [#539](#539) * **max line length:** fixes issues around max line length not fully respected on indented lines ([1ec6b29](1ec6b29)), closes [#580](#580) * **preserving space:** misc improvements for the preserve leading space option ([03ee6f0](03ee6f0)), closes [#566](#566)
🎉 This issue has been resolved in version 1.19.17 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Preliminary testing looks good; I'll know more in a few days when I have a chance to use it against some gnarlier templates. Thanks! |
System Info
Issue
Can't stop
{% for %}...{% endfor %}
block from being collapsed down to a single line.Slightly longer description
I'm attempting to use jinja2 to output YAML. I've inherited a stack of .j2 files with zero indentation for the
{% %}
control blocks anddjlint
seemed like a good tool to use to try and fix this. Because it's YAML, whitespace needs to be preserved. You may be saying to yourself "Yes, but there's a config parameter for that", however see below.How To Reproduce
Here's my current
.djlintrc
:Using
preserve_leading_space
is certainly acres better than not using it, however given this jinja snippet:...which will render this YAML:
...
djlint --reformat
outputs this:...which outputs this (obvs invalid) YAML:
I did try the
beast_mode
branch just for grins, and that's...much worse. =)The text was updated successfully, but these errors were encountered: