相关疑难解决方法(0)

VSCode 用换行符破坏 Django 模板标签

问题:

{% extends 'base.html' %} {% block title %} Dashboard {% endblock %} {% block pagetitle %}
Run Code Online (Sandbox Code Playgroud)

变成

{% extends 'base.html' %} {% block title %} Dashboard {% endblock %} {% block
pagetitle %}
Run Code Online (Sandbox Code Playgroud)

请注意,它{% tag %}被换行了。这会导致 django 模板出现语法错误。

我已经尝试了大多数顶级 django 模板扩展,但这并不能解决问题。

我也尝试过这些设置:

    "[html]": {
        "editor.formatOnSave": false,
    },
    "html.format.wrapLineLength": 0,
    "html.format.enable": false,
    "prettier.disableLanguages": ["html"] 
Run Code Online (Sandbox Code Playgroud)

期望的行为:

  1. 自动格式化 *.html 文件,同时保留 django 模板标签,而不用换行符分解它们。
  2. 次优(但可接受)的行为:根本不格式化 *.html 文件。

django django-templates visual-studio-code

8
推荐指数
1
解决办法
2213
查看次数

没有安装“django-html”文件的文档格式化程序

在 vscode 中,用于自动格式化的 shift+alt+f 在 HTML 中有效,但不适用于 Django 模板文件。如何在 VS 代码中使用自动格式化功能?

django autoformatting visual-studio-code

5
推荐指数
2
解决办法
5299
查看次数