小编Fah*_*lah的帖子

django模板上的vscode html autoformat

我喜欢保存autoformat的VSCode,直到它搞砸了我的模板代码.

它错误地将我的django模板语法格式化为一个行代码(有时真的很长).所以没有这个代码

{% for row in 'ABCDEFGH' %}
<tr>
  {% for col in '123456789012345' %}
    <td>
      {% with forloop.counter|stringformat:"s" as counter %}
        {% with row|add:counter as seat_num %}
          {% if seat_num not in oc_seats %}
            <input type="checkbox" value="{{ row }}{{ forloop.counter }}" name="seats">
          {% endif %}
          <br> {{ seat_num }} 
        {% endwith %}
      {% endwith %}
     </td>    
   {% endfor %}
</tr>
{% endfor %}
Run Code Online (Sandbox Code Playgroud)

我最终得到了这个代码

{% for row in 'ABCDEFGH' %}
<tr>
  {% for col in '123456789012345' %}
  <td style="text-align: …
Run Code Online (Sandbox Code Playgroud)

html django django-templates visual-studio-code

13
推荐指数
6
解决办法
7875
查看次数