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

Format HTML like Prettier #68

Open mubaraqwahab opened 3 years ago

mubaraqwahab commented 3 years ago

Thank you so much for this plugin. I've been looking for the like of it for a while now!

I noticed the plugin doesn't format HTML like how Prettier's own HTML formatter normally does. For example, given this snippet:

<h1>{{ hello | world }}</h1>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">Click me!</button>

Prettier changes it into the following: (playground)

<h1>{{ hello | world }}</h1>
<button
  type="button"
  class="btn btn-primary"
  data-toggle="modal"
  data-target="#exampleModal"
>
  Click me!
</button>

But this plugin (v0.4.6) changes it to:

<h1>
  {{ hello | world }}
</h1>
<button type="button"
  class="btn btn-primary"
  data-toggle="modal"
  data-target="#exampleModal">
  Click me!
</button>

My Observations

It would be nice to have this plugin imitate Prettier's formatting. If you're cool with this proposal (and I hope you are 😃) I could create a pull request to try to resolve this.

Thank you.

mubaraqwahab commented 3 years ago

Whoever's reading this and wants my suggestions, I made a plugin for this Prettier plugin that adds the features in the meantime: prettier-plugin-twig-enhancements.