问题:当我自动意图时,它会删除模板中任何标记/ python逻辑的所有缩进。
是否有一个插件可以为Django模板提供自动缩进功能?如果没有,我如何编辑Auto-indent Lines
命令⌃⌥I
以支持下述格式:
的index.html:
{% block title %}
{# note the indent here with django logic #}
{% render title_tag with title="Sign up Now" global=global %}
{% endblock %}
{% block description %}
{# note the indent here with html markup #}
<meta name="description" content="Sign up today with our product.">
{% endblock %}
{% block body %}
{# note the indent here If statement #}
{% if true %}
<section class="section">
<p> here too</p>
</section>
{% if false %}
<div>
<p>wowo</p>
</div>
{% endif %}
{% endif %}
答案 0 :(得分:1)
<强>答案:强>
为了正确地格式化这些东西(例如在块内保留缩进),IDE必须理解Django标记。 WEB-7814 ticket正在询问(明星/投票/评论以获得任何进展通知)。
现在我可能只建议尝试安装“Twig Support”插件(应该与WebStorm一起使用)。 Twig使用非常相似的语法(灵感来自Django),因此应该在这里提供帮助。否则 - 使用Python插件的PyCharm或完整的IntelliJ。