djlint / djLint

✨ HTML Template Linter and Formatter. Django - Jinja - Nunjucks - Handlebars - GoLang
https://djLint.com
GNU General Public License v3.0
686 stars 84 forks source link

[BUG] [Formatter] Incorrect indentation around `timezone` tags #819

Open samamorgan opened 7 months ago

samamorgan commented 7 months ago

System Info

Issue

The formatter incorrectly indents around timezone tags.

How To Reproduce

The following code pasted into a template

<div>
  <div>
    {% timezone object.zone_info %}
      <p>{% now "F jS, Y h:i A e" %}</p>
    {% endtimezone %}
  </div>
</div>

Indents like so

<div>
  <div>
    {% timezone object.zone_info %}
    <p>{% now "F jS, Y h:i A e" %}</p>
  {% endtimezone %}
</div>
</div>
samamorgan commented 7 months ago

Note: I was able to resolve this by adding custom_blocks = "timezone" to pyproject, but this is a Django feature and should be internally recognized by djlint

SilvanVerhoeven commented 2 months ago

@samamorgan I am having the same issue with blocktrans, but setting custom_blocks = "blocktrans" doesn't do anything for me. Is it the same for you?