简体   繁体   English

在 Visual Studio Code 中向 django-html 文件添加格式化程序(美化器)

[英]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.我正在使用 Django 扩展来在 Jinja 模板(VS Code)上进行智能感知和语法突出显示,但无法弄清楚如何使用我的默认格式化程序(HookyQR Beautify)来美化/格式化我的 django-html 文件。 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, 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.所以我从小语言中禁用了django-html ,并使用了从这个问题讨论中获得的这些设置。 , 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:这似乎已经为我排序,允许我为普通的 HTML 文件保留 HookyQR Beautify,并为 django-html 文件保留一个单独的文件:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Visual Studio Code 中同时自动完成 HTML 和 Django-HTML? - How can I autocomplete both HTML and Django-HTML simultaneously in Visual Studio Code? 如果文件关联设置为 django-html,则 html 的 Intellisense 不起作用 - Intellisense for html does not work if file association set to django-html Visual Studio 2008 HTML自动格式化程序 - Visual Studio 2008 HTML auto-formatter Visual Studio 代码无法识别 html 文件 - visual studio code not recognizing html files HTML 文件中的 Visual Studio 代码注释 - Visual studio code comment in HTML files Django VSCode:如何按预期制作 django-html 格式? - Django VSCode: How to make django-html format as expectedl? Django-HTML:我如何允许用户添加额外的输入字段(确保它们不是必需的)? 类似于 + 按钮的东西 - Django-HTML: How can i allow users to add additional input fields (ensuring they are not required)? Something like a + button 如何将 Django-Html web 页面导出为 xml 文件 - How to export a Django-Html web page as an xml file 将 Django-HTML 表单输入与列表中的元素进行比较 - Compare Django-HTML form input with the elements in a list 如何在 vscode 的 django-html 文件中启用 css 建议? - How to enable css suggestions in django-html file in vscode?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM