djLint icon indicating copy to clipboard operation
djLint copied to clipboard

[FEATURE] [FORMATTER] "for" is formatted in a single line when "for else" is not

Open scratchmex opened this issue 2 years ago • 2 comments

  • [X] I've searched the issues
  • [X] I've read the docs

Feature Request

{% for (id, name) in accounts %}
    <option value="{{ id }}">{{ name }}</option>
{% endfor %}


{% for (id, name) in campaigns %}
    <option value="{{ id }}">{{ name }}</option>
{% else %}
    <option selected hidden value="">no campaigns found</option>
{% endfor %}

will be formatted to

{% for (id, name) in accounts %}<option value="{{ id }}">{{ name }}</option>{% endfor %}
{% for (id, name) in campaigns %}
    <option value="{{ id }}">{{ name }}</option>
{% else %}
    <option selected hidden value="">no campaigns found</option>
{% endfor %}

can we let the for be in multiline form for readability?

also, is there a way to disable the stripping of multiple breaklines? it is putting the 2 fors together and that breaks readability also

scratchmex avatar Jul 29 '23 19:07 scratchmex

Thanks for opening your first issue here!

welcome[bot] avatar Jul 29 '23 19:07 welcome[bot]

Hey, both of these are config options. The first is max line length, and the second is max blank lines.

christopherpickering avatar Jul 30 '23 18:07 christopherpickering