【问题标题】:Keyboard shortcut for {% %} in VSCode using Django HTML使用 Django HTML 的 VSCode 中 {% %} 的键盘快捷键
【发布时间】:2020-07-29 02:47:00
【问题描述】:

我正在构建我的第一个 Django 应用程序并在我的 html 文件中使用 Django 模板引擎。我在 VSCode 中有 html 和 Django html 插件。

到目前为止,它会自动完成 html 元素并为 Django 模板着色。

在 VSCode 中使用 Django HTML 语言模式时,有没有办法自动完成 {% %}

【问题讨论】:

    标签: python django python-3.x django-templates jinja2


    【解决方案1】:

    您必须将以下配置添加到您的 VS Code 设置中才能完全扩展,并且您的文件必须位于名为 templates 的文件夹或其子文件夹中,如果您希望您的模板位于不同的文件夹,您可以根据您的配置更改设置

    "files.associations": {
        "**/*.html": "html",
        "**/templates/**/*.html": "django-html",
        "**/templates/**/*": "django-txt",
        "**/requirements{/**,*}.{txt,in}": "pip-requirements"
    },
    
    
    
    "emmet.includeLanguages": {"django-html": "html"},
    

    您可以在扩展程序GitHub page 中找到更多详细信息

    【讨论】:

      【解决方案2】:

      您可以使用 django-Intellisense VSCode 扩展来为 Django 生成的所有动态属性提供自动完成功能。

      【讨论】:

      • 好的,谢谢,会的。有没有办法在 settings.json 中进行设置?还是即插即用?
      • 你可以通过从 VSCode Marketplace 下载来开始使用扩展的功能。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-02-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多