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] Block HTML tags used as parameters for macro functions cause unneeded carriage returns #353

Closed
3 tasks done
BrokenEagle opened this issue Aug 28, 2022 · 1 comment
Labels

Comments

@BrokenEagle
Copy link

System Info

  • OS: Windows 8.1
  • Python Version (3.7.9)
  • djLint Version (1.12.0)
  • template language: jinja

Issue

Using block HTML tags inside macro function parameters causes the formatter to put a carriage return before and after the HTML tag.

How To Reproduce

Example test file and configuration have been included at the end. When executing the command djlint --check test.html , it produces the following output.

@@ -1,4 +1,6 @@

-{% call (a, b) render_form(form, '<hr>'>) %}
+{% call (a, b) render_form(form, '
+    <hr>
+    '>) %}
     {% if a == 'foo' %}
         {{ b('bar') }}
     {% else %}
@@ -9,7 +11,7 @@

 {% call render_form(form, '<a>'>) %}
     <span>No form.</span>
 {% endcall %}
-
 {{ item_block(form, '<span>') }}
-
-{{ item_block(form, '<div>') }}
+{{ item_block(form, '
+<div>
+    ') }}

As can be seen, when inline HTML tags like <a> and <span> are used, then there is no issue. However, when block HTML tags like <hr> or <div> are used, it adds a carriage return before or after. Using single or double-quoted strings did not seem to matter. Although not shown, other block tags like <br> had the same behavior as <hr> and <div>.

Files used

@BrokenEagle BrokenEagle added 🦠 bug Something isn't working 🧽 formatter labels Aug 28, 2022
@BrokenEagle BrokenEagle changed the title [BUG] [Formatter] [BUG] [Formatter] Block HTML tags used as parameters for macro functions cause unneeded carriage returns Aug 29, 2022
christopherpickering pushed a commit that referenced this issue Aug 30, 2022
## [1.12.1](v1.12.0...v1.12.1) (2022-08-30)

### Bug Fixes

* **macro:** allow html tags inside macro functions to skip formatting ([bffb093](bffb093)), closes [#353](#353)
* **t001:** fixed false positive on T001 with Jinja {{- and {{+ tags ([c57e944](c57e944)), closes [#354](#354)
@christopherpickering
Copy link
Contributor

🎉 This issue has been resolved in version 1.12.1 🎉

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