gpt4 book ai didi

visual-studio-code - 如何在 vscode 中为 HTML 和 Jinja 设置格式化程序?

转载 作者:行者123 更新时间:2023-12-04 04:26:06 24 4
gpt4 key购买 nike

我正在使用 vs 代码,它具有自动格式化功能,这很棒,但是,当我编写 HTML 文件并使用 Jinja 或 DTL 时,它的格式非常糟糕。如何为此禁用格式或更改它?

我已经安装了一个名为 Prettier 的格式化扩展。

这就是我得到的:

{{ block.super }}

{% endblock styling%} {% block title %} Game {{ game.firs_player }} vs.
{{ game.second_player }} {% endblock title %} {% block content %} This is a
detial page for game {{ game.id }}
{% endblock content %}

这就是我要的:
{% load staticfiles %} 

{% block styling%}
{{ block.super }}
{% endblock styling%}

{% block title %}
Game {{ game.firs_player }} vs.{{ game.second_player }}
{% endblock title %}

{% block content %}
This is a detial page for game {{ game.id }}
{% endblock content %}```

最佳答案

您可以使用 beautify .它并不完美,但它有效。
安装后添加到您的用户 settings.json文件,此代码:

"beautify.language": {
"js": {
"type": [
"javascript"
],
"filename": [
".jshintrc",
".jsbeautifyrc"
]
// "ext": ["js", "json"]
// ^^ to set extensions to be beautified using the javascript beautifier
},
"css": [
"css",
"scss"
],
"html": [
"htm",
"html",
"django-html"
]
// ^^ providing just an array sets the VS Code file type
},

它现在应该可以与 Django 模板文件一起使用。

关于visual-studio-code - 如何在 vscode 中为 HTML 和 Jinja 设置格式化程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56078425/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com