Gui*_*tta 5 html jinja2 visual-studio-code
我在一些教程中看到,有些教程设法对 Visual Studio Code 上的 html 文件中注入的 jinja 模板使用智能感知和语法突出显示,但我找不到实现它的方法。我安装了 Jinja 和 Better Jinja 扩展,但我无法使它们工作。需要明确的是,我希望在 HTML 文件中为代码(例如下面的代码)提供智能感知和语法突出显示。
<p>
{% if music_style %}
The style you entered is {{ music_style }}
Update it in the form below
{% else %}
Please enter your style:
{% endif %}
</p>
Run Code Online (Sandbox Code Playgroud)
在 VS Code 右下角的状态栏中有一个更改语言的选项,
从 HTML,通过单击它并在搜索选项上搜索然后选择它,将其更改为 Django HTML。
在settings.json文件中,您可以添加以下代码,以便大多数时候django模板将被视为django-html,其他时候将被视为html
"files.associations": { // so that all html files are not recognized as django-html
"**/templates/**/*.html": "django-html",
"*.html": "html"
},
Run Code Online (Sandbox Code Playgroud)
希望对您有帮助,
谢谢!