【问题标题】:Jinja intellisense and syntax highlighting in VS CodeVS Code 中的 Jinja 智能感知和语法高亮显示
【发布时间】:2020-07-27 05:13:29
【问题描述】:

我在一些教程中看到,有些教程设法为在 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>

【问题讨论】:

    标签: html visual-studio-code jinja2


    【解决方案1】:

    在 VS 代码右下角的状态栏中,有一个更改语言的选项,
    从 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"
    },
    

    希望对你有帮助,
    谢谢!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-12-02
      • 1970-01-01
      • 2017-06-06
      • 2019-12-08
      • 1970-01-01
      • 2015-11-07
      • 2016-02-15
      • 1970-01-01
      相关资源
      最近更新 更多