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] Some formatting happens in {# djlint:off #} and {# djlint:on #} blocks #824

Open
3 tasks done
davepeck opened this issue Mar 29, 2024 · 0 comments
Open
3 tasks done
Labels
🦠 bug Something isn't working 🧽 formatter

Comments

@davepeck
Copy link

davepeck commented Mar 29, 2024

System Info

  • OS: macOS sonoma 14.4.1
  • Python Version: 3.12.2
  • djLint Version: 1.34.1
  • template language: django

Issue

Some formatting happens, even between {# djlint:off #} and {# djlint:on #} pragmas.

How To Reproduce

Save an example.html file with the following indentation:

<div>
    {# djlint:off #}
    <style>
    </style>
    {# djlint:on #}
    <p>Hello, world!</p>
</div>

Then run djlint --reformat example.html and notice what happened to the closing </style> tag:

<div>
    {# djlint:off #}
    <style>
</style>
    {# djlint:on #}
    <p>Hello, world!</p>
</div>

PS: there is another off/on pragma bug described in this separate issue that I'm also able to reproduce with 1.34.1. However, I don't believe this bug and that bug are related.

Wait, <style> tags in the middle of templates?

I use css-scope-inline, so my Django templates tend to have <style> tags nested in them.

Because my styles sometimes have template substitutions in them (color: {{ color }};), I tend to wrap them with on/off pragmas ({# djlint:off #}). This bug doesn't require format_css to be enabled.

@davepeck davepeck added 🦠 bug Something isn't working 🧽 formatter labels Mar 29, 2024
@davepeck davepeck changed the title [BUG] [Formatter] Some formatting happens in {# djlint: off #} and {# djlint: on #} blocks [BUG] [Formatter] Some formatting happens in {# djlint:off #} and {# djlint:on #} blocks Mar 29, 2024
@davepeck davepeck changed the title [BUG] [Formatter] Some formatting happens in {# djlint:off #} and {# djlint:on #} blocks [BUG] [Formatter] Some formatting happens in {# djlint:off #} and {# djlint:on #} blocks Mar 29, 2024
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

1 participant