Skip to content

[BUG] [Formatter] Djlint condenses Jinja tags from multiple lines into one #1597

@IArnaut2

Description

@IArnaut2

System Info

  • OS: Windows 11 64-bit
  • Python Version 3.14.2
  • djLint Version 1.36.4
  • template language: Django Template

Issue

Djlint has stupid the annoying issue where it wraps condensing Jinja tags from multiple lines into one line.

Example #1:
Before:

{{ terms_form.move_in_date }}
{% if terms_form.move_in_date.errors %}
<span class="form-text text-danger">{{ terms_form.move_in_date.errors.0 }}</span>
{% endif %}

Example #1 after:

{{ terms_form.move_in_date }} {% if terms_form.move_in_date.errors %}
<span class="form-text text-danger">{{ terms_form.move_in_date.errors.0 }}</span>
{% endif %}

Example #2:
Before:

{% csrf_token %}

{% if messages %}
  {% for message in messages %}
  <div class="row mb-3">
    <div class="col">
      <div class="alert alert-danger">{{ message }}</div>
    </div>
  </div>
  {% endfor %}
{% endif %}

After:

{% csrf_token %} {% if messages %} {% for message in messages %}
<div class="row mb-3">
  <div class="col">
    <div class="alert alert-danger">{{ message }}</div>
  </div>
</div>
{% endfor %} {% endif %}

How To Reproduce

  1. Just write code like in the examples before formatting
  2. Save file

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions