Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 300
Guillermo Brachetta Avatar asked Nov 01 '25 03:11

Guillermo Brachetta


2 Answers

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"
    }
  }
like image 139
Akshay Chandran Avatar answered Nov 03 '25 18:11

Akshay Chandran


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"
    ]
}
like image 30
Guillermo Brachetta Avatar answered Nov 03 '25 20:11

Guillermo Brachetta



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!