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] Conditional HTML enclosing tags leads to added indentation #840

Open
3 tasks done
PetrDlouhy opened this issue Jun 10, 2024 · 0 comments
Open
3 tasks done
Labels
🦠 bug Something isn't working 🧽 formatter

Comments

@PetrDlouhy
Copy link

PetrDlouhy commented Jun 10, 2024

System Info

  • OS: Ubuntu 23.1
  • Python Version (python --version): Python 3.11.6
  • djLint Version (djlint --version): version 1.34.1
  • template language: Django

Issue

If I want to add/not add enclosing HTML tag in my template I do it like this:

{% if enclose_in_dif %}
    <div>
{% endif %}

<h1>Test</h1>

{% if enclose_in_dif %}
    </div>
{% endif %}

When I run djlint --reformat, I got this result:

{% if enclose_in_dif %}<div>{% endif %}
    <h1>Test</h1>
    {% if enclose_in_dif %}</div>{% endif %}

Which is the worst possibility what could have happened. It will introduce new indentation in the document.

My pyproject.toml:

  [tool.djlint]
  profile="django"
  custom_blocks="cache,scribble,experiment,recursetree,linebreakless,blocktrans,html2text"
  custom_html="source,picture,img,defs,symbol,path"
@PetrDlouhy PetrDlouhy added 🦠 bug Something isn't working 🧽 formatter labels Jun 10, 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