trivago / prettier-plugin-twig-melody

Code formatting plugin for Prettier which can handle Twig/Melody templates
Apache License 2.0
155 stars 35 forks source link

The plugin removes all blank lines, which I think it shouldn't. #103

Open grndctrl opened 1 year ago

grndctrl commented 1 year ago

I like to keep my html-code separated from twig-code with blank lines.

<section>

  {% if condition %}
    {% set var = value %}
  {% endif %}

  <div class="container">
    {{ var }}
  </div>

</section>

However the plugin ignores my single blank line formatting and removes some of them. And although it's compact, it's not "pretty". I don't see why there the blank after the if statement is kept while others are removed.

<section>
  {% if condition %}
    {% set var = value %}
  {% endif %}

  <div class="container">
    {{ var }}
  </div>
</section>

I think this is wrong, as the official prettier docs state that prettier collapses multiple blank lines into one, but single empty lines are allowed.

Now I understand changing this might impact other codebases heavily, so I'd like to see a twigAllowSingleEmptyLines option or something like that.