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] format_attribute_template_tags option makes URLs in tags attributes unreadable #427

Closed
3 tasks done
monosans opened this issue Oct 15, 2022 · 3 comments
Closed
3 tasks done
Labels

Comments

@monosans
Copy link
Member

System Info

  • djLint v1.19.1

Issue

format_attribute_template_tags option makes URLs in tags attributes unreadable.

How To Reproduce

<a class="page-link" href="?{% if foo %}foo={{ foo }}&amp;{% endif %}bar={{ bar }}"></a>

This is reformatted like this:

<a class="page-link"
   href="?
         {% if foo %}
           foo={{ foo }}&amp;
         {% endif %}
         bar={{ bar }}"></a>

This makes the resulting URL unreadable and ugly due to spaces. Example: http://127.0.0.1:8000/?%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20foo=foo&%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20bar=bar
I suggest making format_attribute_template_tags ignore the formatting of attributes such as <form>'s action, <a>'s href, <img>'s and <video>'s src, and maybe a few others I forgot about.

Config

[tool.djlint]
format_attribute_template_tags = true
@monosans monosans added 🦠 bug Something isn't working 🧽 formatter labels Oct 15, 2022
@christopherpickering
Copy link
Contributor

Thanks, we should probably ignore attribute values when doing the formatting.

@christopherpickering
Copy link
Contributor

@monosans I rewrote the regex for the attribute parsing so that it will give me back groups : name, value, or just value. I need to rewrite the attirubute formatting code, hopefully next week, to fix this problem.

christopherpickering pushed a commit that referenced this issue Nov 3, 2022
## [1.19.4](v1.19.3...v1.19.4) (2022-11-03)

### Bug Fixes

* **attributes:** fixed poor django attribute parsing ([bd90f08](bd90f08)), closes [#427](#427) [#438](#438)
* **attributes:** prevented attribute indentation for url type attributes ([907a1bf](907a1bf)), closes [#320](#320) [#86](#86) [#195](#195)
* **image tag:** added image tag to template break tag list. srcset formatting ([0d170aa](0d170aa)), closes [#444](#444)
@christopherpickering
Copy link
Contributor

🎉 This issue has been resolved in version 1.19.4 🎉

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