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] Nunjucks filters with arguments incorrectly formatted #720

Open
3 tasks done
aarongoldenthal opened this issue Jul 20, 2023 · 1 comment
Open
3 tasks done
Labels
🦠 bug Something isn't working 🧽 formatter

Comments

@aarongoldenthal
Copy link

System Info

  • OS: Windows 11, Alpine Linux
  • Python Version (python --version): 3.10.11
  • djLint Version (djlint --version): 1.32.0
  • template language: nunjucks

Issue

The formatting is incorrectly formatting Nunjucks filters with arguments - the filters are removed, and properties of the argument are appended to the previous argument. For example:

-    {% set absoluteUrl %}{{ page.url | htmlBaseUrl(metadata.url) }}{% endset %}
+    {% set absoluteUrl %}{{ page.url.url }}{% endset %}

-        {{ post.templateContent | transformWithHtmlBase(absolutePostUrl, post.url) | dump | safe }}
+        {{ post.templateContent.url | dump | safe }}

This appears to have starting with v1.32.0 (and I'd guess related to #704).

How To Reproduce

Run djlint --check . with the following config:

{
  "blank_line_after_tag": "extends, include",
  "blank_line_before_tag": "extends, include",
  "extension": "njk",
  "indent": "4",
  "ignore_blocks": "set",
  "format_attribute_template_tags": true,
  "format_css": false,
  "format_js": false,
  "max_attribute_length": "100",
  "max_line_length": "120",
  "no_line_after_yaml": true,
  "preserve_blank_lines": true,
  "preserve_leading_space": false,
  "profile": "nunjucks",
  "require_pragma": false,
  "use_gitignore": true
}
@aarongoldenthal aarongoldenthal added 🦠 bug Something isn't working 🧽 formatter labels Jul 20, 2023
@christopherpickering
Copy link
Contributor

Thanks for reporting! Shucks, I don't have time to fix right now so I will roll back that update until we can figure out a better plan.

christopherpickering added a commit that referenced this issue Jul 20, 2023
This update reverts the formatting on of chained functions as it broke filter strings, but at the
same time leaves in a fix for extra spaces that the original issue found.

re #720, #704
christopherpickering pushed a commit that referenced this issue Jul 20, 2023
## [1.32.1](v1.32.0...v1.32.1) (2023-07-20)

### Bug Fixes

* **formatter:** reverted chained function formatting ([2ba6e3b](2ba6e3b)), closes [#720](#720) [#704](#704)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🦠 bug Something isn't working 🧽 formatter
Projects
None yet
Development

No branches or pull requests

2 participants