【发布时间】:2016-04-18 16:20:41
【问题描述】:
问题:当我自动意图时,它会删除模板中任何标记/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 %}
【问题讨论】:
-
我真的怀疑使用任何捆绑/默认的东西可以在这里完成任何事情。为了或多或少正确地格式化这些东西(例如,在块中保持缩进)IDE 必须理解 Django 标签。 WEB-7814ticket 就是在问这个问题(星/投票/评论以获得任何进展的通知)。现在我可能只建议尝试安装“Twig Support”插件(应该与 WebStorm 一起使用)——它使用非常相似的语法,所以在这里应该有所帮助。否则 -- PyCharm 或带有 Python 插件的 IntelliJ
-
Ayeee 这已经足够好了!谢谢!
-
这真的很有帮助@LazyOne 如果您想将其作为答案,我会将其标记为正确并投票!
标签: python html django webstorm code-formatting