Skip to content
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] Whitespace control incorrectly formatted for variable blocks works since 1.28.0 #667

Closed
3 tasks done
NVolcz opened this issue May 23, 2023 · 6 comments
Closed
3 tasks done
Labels

Comments

@NVolcz
Copy link

NVolcz commented May 23, 2023

System Info

  • OS: Ubuntu 22.04.02
  • Python Version: 3.10.6
  • djLint Version: 1.28.0
  • template language: Nunjucks

Issue

This:

Some {{- thing }}

gets formatted into this (notice the whitespace between {{ and -):

Some {{ - thing }}

From the nunjucks documentation:

And the same is for variables: {{- will strip the whitespace before the variable, and -}} will strip the whitespace after the variable.

How To Reproduce

  1. Install 1.27.2 and format the template above (nothing should happen).
  2. Upgrade to 1.28.0
  3. Format the template again.
@NVolcz NVolcz added 🦠 bug Something isn't working 🧽 formatter labels May 23, 2023
@christopherpickering
Copy link
Contributor

@NVolcz Thanks for all your issues, I appreciate you finding these bugs :) I'm looking forward to the day you will also send a PR 😁 I'll get this fixed soon.

@NVolcz
Copy link
Author

NVolcz commented May 23, 2023

The pleasure is mine 🙂. I am slowly getting to know the code base.

@christopherpickering
Copy link
Contributor

@NVolcz can you send me your config? With the default config I can't reproduce it:

image

@NVolcz
Copy link
Author

NVolcz commented May 30, 2023

Of course:

{
  "profile": "nunjucks",
  "indent": "2",
  "custom_blocks": "switch",
  "blank_line_after_tag": "endblock, endmacro, extends",
  "no_line_after_yaml": true
}

@NVolcz
Copy link
Author

NVolcz commented May 30, 2023

Sorry. My test case is bad. Here is a better one:

{% macro test(a) %}
{% endmacro %}
{{- foo("bar") -}}

christopherpickering pushed a commit that referenced this issue May 30, 2023
# [1.30.0](v1.29.0...v1.30.0) (2023-05-30)

### Bug Fixes

* **formatter:** fixed endset indent level ([cdebe42](cdebe42)), closes [#670](#670)
* **formatter:** fixed issue with spaceless macro tags having spacess added before - ([5593937](5593937)), closes [#667](#667)
* **npm:** install exact version of djlint ([0727279](0727279))

### Features

* **npm:** add script to update djlint version in postinstall using semantic-release/exec ([040ffc6](040ffc6))
@christopherpickering
Copy link
Contributor

🎉 This issue has been resolved in version 1.30.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants