djlint / djLint

✨ HTML Template Linter and Formatter. Django - Jinja - Nunjucks - Handlebars - GoLang
https://djLint.com
GNU General Public License v3.0
668 stars 82 forks source link

[BUG] [Formatter] Nunjucks filters with arguments incorrectly formatted #720

Open aarongoldenthal opened 1 year ago

aarongoldenthal commented 1 year ago

System Info

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 https://github.com/Riverside-Healthcare/djLint/issues/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
}
christopherpickering commented 1 year ago

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.