djLint icon indicating copy to clipboard operation
djLint copied to clipboard

[BUG] [Formatter] Incorrect indentation with template tags which do not have a {% endtag %}

Open jmichalicek opened this issue 9 months ago • 2 comments

System Info

  • OS: Debian Bookworm
  • Python Version (python --version): 3.12.2
  • djLint Version (djlint --version): 1.36.4
  • template language: e.g. mustache: Django

Issue

Template tags do not format as expected if there is a template tag with no explicit ending tag;

{% if album.owner.profile_picture %}
  {% thumbnail "250x250" album.owner.profile_picture -- alt="Album owner profile image" class="rounded-full w-24 h-24" %}
  {% else %}
     <img src="{% static 'svg/icon-user-default.svg' %}"
               alt="user"
               class="rounded-full w-24 h-24">
  {% endif %}

Everything from {% else %] through {% endif %} should be dedented one level. This then continues to throw off the formatting throughout the rest of the html afterwards.

jmichalicek avatar Feb 26 '25 00:02 jmichalicek

While I saw it previously, and not technically the same in how we are reporting it, it looks like this is the same issue as #1113

jmichalicek avatar Feb 26 '25 01:02 jmichalicek

Was just checking on the status and saw #168 called out at the top of the issues now which will resolve this.

jmichalicek avatar Mar 18 '25 12:03 jmichalicek