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

feature_request(H021): allow inline styles if templates in styles #351

Closed
3 tasks done
Kristinita opened this issue Aug 24, 2022 · 3 comments
Closed
3 tasks done
Labels

Comments

@Kristinita
Copy link

Kristinita commented Aug 24, 2022

1. Summary

Possibly, it would be nice, if djLint will allow inline styles if they contain at least one template.

That is, if the value of the style attribute contain {{ braces }}, rule H021 will not apply.

2. Argumentation

The most popular answer on Stack Overflow to the question “What’s so bad about in-line CSS?” says that putting styles into classes can be much easier to maintain.

But in some cases, inline-styles can be easier to maintain. See my real example below. In my opinion, for such cases, it makes sense not to apply rule H021.

3. MCVE

3.1. File to check

  • KiraDJLint__inline-styles-with-templates--H021.html

     {# [INFO] MCVE #}
     <div style="background-image: url({{ kira_icon }}.webp)"></div>
    
    
     {# [INFO] Real example.
    
     Templates for the pure CSS fading slideshow:
     https://codeconvey.com/pure-css-fading-slideshow/ #}
     <div class="KiraSlider">
    
     	{% set kira_404_icons_list = [
     			("SashaNose", "1"),
     			("SashaRiver", "2"),
     			("SashaBlueHairs", "3"),
     			("SashaBow", "4"),
     			("SashaPigeon", "5"),
     			("SashaShimskyNovgorodDestrict", "6"),
     			("SashaWeddingOfFriends", "7")
     		]
     	%}
    
     	{% for kira_icon, kira_icon_number in kira_404_icons_list %}
     		<div class="KiraFadeSlideshowIcon{{ kira_icon_number }}" style="background-image: url({{ SITEURL }}/{{ THEME_STATIC_DIR }}/images/404/{{ kira_icon }}.webp)"></div>
     	{% endfor %}
    
     </div>
    

3.2 Desired behavior

No errors

3.3. Current behavior

D:\SashaDebugging\KiraDJLintDebuging>djlint --profile=jinja --lint KiraDJLint__inline-styles-with-templates--H021.html --ignore=T001

Linting 1/1 files ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 00:00


SashaDebugging\KiraDJLintDebuging\KiraDJLint__inline-styles-with-templates--H021.html
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── H021 2:0 Inline styles should be avoided. <div style=
H021 24:2 Inline styles should be avoided. <div class="KiraFade

Linted 1 file, found 2 errors.

4. Environment

  1. Microsoft Windows [Version 10.0.19041.1415]
  2. Python 3.10.6
  3. djlint, version 1.11.1
  4. Template language — Jinja

5. Checkbox

  1. I’m on the latest version of djLint
  2. I’ve searched the issues
  3. I’ve read the docs

Thanks.

@christopherpickering
Copy link
Contributor

Its a good point.

christopherpickering pushed a commit that referenced this issue Aug 24, 2022
# [1.12.0](v1.11.1...v1.12.0) (2022-08-24)

### Bug Fixes

* **h006:** prevented false positives on H006 ([215bd23](215bd23)), closes [#344](#344) [#333](#333)
* **h012:** prevent H012 from matching the contents of tags or attributes ([4480cff](4480cff)), closes [#348](#348)
* **t001:** fixed false positive on multiline template tags ([ea76672](ea76672)), closes [#350](#350)

### Features

* **h021:** allow inline styles that contain template syntax ([f1a39ed](f1a39ed)), closes [#351](#351)
* **t002:** allow variables names to be used in the {% extends tag ([a5d96e7](a5d96e7)), closes [#349](#349)
@christopherpickering
Copy link
Contributor

🎉 This issue has been resolved in version 1.12.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@Kristinita
Copy link
Author

Status: FIXED ✔️ for me for djLint 1.12.0.

Thanks.

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