简体   繁体   中英

Add a formatter (beautifier) to django-html files in Visual Studio Code

I'm using the Django extension for intellisense and syntax highlighting on Jinja templates (VS Code) but cannot figure out how to use my default formatter (HookyQR Beautify) to beautify/format my django-html files. Would that be possible?

I need to use beautify only for django-html files, I've got prettier working for js, html, css then flake8 and autopep8 for python, for django-html prettier wrongly formats jinja template strings,

so I disabled the django-html from pettier languages and used these settings got from this issue discussion. , works for me well.

{
    "prettier.disableLanguages": ["django-html"],
    "beautify.language": {
      "html": [
        "django-html"
      ]
    },
    "[django-html]": {
      "editor.formatOnSave": true,
      "editor.defaultFormatter": "HookyQR.beautify"
    }
  }

This seems to have sorted it for me, allowing me to keep HookyQR Beautify for normal HTML files and have a separate one for django-html files:

"beautify.language": {
    "html": [
        "django-html"
    ]
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM