3
"html.format.templating": false,

文档中有这个设置,与 vscode 相关。它有一个定义,但还不够清楚,我们必须将其设置为trueor flase?甚至值得,设置哪个语句都没有关系。美化不在乎。它总是会格式化(django-tamplate)标签。

<ul class="navbar-nav nav-flex-icons {% if LANGUAGE_BIDI %} mr-auto {% endif %}">
    {% get_available_languages as languages %}
    {% for lang_code, lang_name in languages %}
    {% if lang_code != LANGUAGE_CODE %}
    {% language lang_code %}
    <li class="nav-item">
      <a class="nav-link lang-setter" data-lang-code="{{ lang_code }}">
        {{ lang_code|language_name_local }}
      </a>
    </li>
    {% endlanguage %}
    {% endif %}
    {% endfor %}
</ul>

这就是结果。我还提供了所需的缩进规则,但我无法找到一种方法来为 vscode 代码格式化程序(如 beautify 或 prettier)强制执行此规则。

  "indentationRules": {
      "increaseIndentPattern": "((\\<)(body|address|blockquote|dd|div|dl|dt|tr|tbody|thead|fieldset|form|frame|frameset|h1|h2|h3|h4|h5|h6|iframe|noframes|object|ol|p|ul|applet|center|dir|a|menu|pre|table|button|a|abbr|acronym|area|b|base|basefont|bdo|big|br|button|caption|cite|code|col|colgroup|del|dfn|em|font|head|html|i|img|input|ins|isindex|kbd|label|legend|li|link|map|meta|noscript|optgroup|option|param|q|s|samp|script|select|small|span|strike|strong|style|sub|sup|table|tbody|td|textarea|tfoot|th|thead|title|tr|tt|u|var))|(\\{\\%)\\s*(autoescape|block|blocktrans|blocktranslate|comment|for|empty|if|elif|else|ifchanged|ifequal|ifnotequal|from|low|regroup|ssi|spaceless|templatetag|widthratio|with|verbatim|thumbnail)",
      "decreaseIndentPattern": "((\\<\\/)(.*)*(\\>))|((\\{\\%)\\s*(empty|elif|else|end(autoescape|block|blocktrans|blocktranslate|comment|for|if|ifchanged|ifequal|ifnotequal|spaceless|with|verbatim|thumbnail)))"
      }
4

0 回答 0