prettier-vscode icon indicating copy to clipboard operation
prettier-vscode copied to clipboard

Prettier can't differentiate classic HTML files from Django HTML templates

Open ddahan opened this issue 3 years ago • 1 comments

Summary

I can't prevent Prettier to run with Django HTML files, while I want to use it with "classic" HTML files only. I don't want to use Prettier to format Django HTML files, because it can't do it and write error in logs if it tries to. Both files have an .html extension and I guess Prettier uses this extension to lint or not.

However, VS Code itself is able to differentiate them after installing a specific extension that add django-html language:

image

Steps To Reproduce:

  1. in your settings: write:
"editor.formatOnSave": true,
"[html]": {"editor.defaultFormatter": "esbenp.prettier-vscode"},
"[django-html]": {"editor.defaultFormatter": null },
  1. install this extension

Expected result

When I save a Django HTML file, I expect Prettier not to be run.

Actual result

Prettier is run, and write an error in logs, since it's unable to parse Django tags.

ddahan avatar May 04 '22 13:05 ddahan

A workaround that does the job:

"[django-html]": {
            "editor.formatOnSave": false
        },

However, I still don't understand why the initial code does not work.

ddahan avatar May 04 '22 14:05 ddahan

This issue has been labeled as stale due to inactivity. Reply to keep this issue open.

github-actions[bot] avatar Apr 22 '23 14:04 github-actions[bot]

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

github-actions[bot] avatar Jul 30 '23 00:07 github-actions[bot]