Skip to content

[BUG] [Formatter] Unexpected (lack of) formatting for {% comment %} tags and their content #1572

@lbligh

Description

@lbligh

System Info

  • OS: MacOS Ventura 13.4
  • Python Version 3.13.11
  • djLint Version 1.36.4
  • template language: django
  • Using the djlint VSCode Extension

Issue

Whether or not comment is added to the "custom blocks" setting, djlint does not indent it as a block. Therefore is can be hard to trace the start and end of the {% comment %}...{% endcomment %} block (and it looks a bit weird to me)

How To Reproduce

With the input:

<div>
{% comment %}
<p>Welcome to djLint online!</p>
{% endcomment %}
</div>

in the try online tool, the ouput is (with and without comment added to "custom blocks"):

<div>
    {% comment %}
<p>Welcome to djLint online!</p>
    {% endcomment %}
</div>

The desired output would be:

<div>
    {% comment %}
        <p>Welcome to djLint online!</p>
    {% endcomment %}
</div>

i.e. treat the comment block as any other block is treated (and how the tag is fornatted in the django docs).
In addition, the opening tag and the closing tag do not get moved to their own line like other multiline comments. I suppose this could be partially due to the {% comment %} tag being used both for single and multiline comments?

I'm not sure if this is a desired feature, or a bug, but it would be nice if it could be possible to control how the tag is formatted.

Thank you in advance!

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