trivago / prettier-plugin-twig-melody

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

Custom language extension support #31

Closed ColdHeat closed 3 years ago

ColdHeat commented 4 years ago

I think this would be a useful prettier plugin for Jinja templates which also have a twig-like syntax.

Only issue is that Flask generally uses the .html extension for HTML files: https://github.com/pallets/flask/blob/38eb5d3b49d628785a470e2e773fc5ac82e3c8e4/src/flask/app.py#L803-L811.

Is it possible to get this plugin to override the prettier default HTML functionality?

adamaveray commented 4 years ago

You can achieve this either by using the CLI option --parser (e.g. prettier --parser melody '**/*.html', or prettier --parser melody '**/*.njk' for Nunjucks, etc) or by defining an override in your Prettier config:

{
  // ...
  "prettier": {
    // ...
    "overrides": [
      {
        "files": "**/*.html",
        "options": {
          "parser": "melody"
        }
      }
    ]
  }
}