Problem: When I auto intent it removes all indentation any markup/python logic in the template.
Is there a plugin to afford auto indent for Django templates? If not, how can I edit the Auto-indent Lines
command ⌃⌥I
to support formatting described below:
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 %}
Answer:
In order to format such stuff more-or-less properly (e.g. keep indentation inside blocks) IDE must understand Django tags. WEB-7814 ticket is asking just about that (star/vote/comment to get notified on any progress).
Right now I may only suggest to try to install "Twig Support" plugin (should work with WebStorm). Twig uses very similar syntax (inspired by Django) so it should help here. Otherwise -- PyCharm or full IntelliJ with Python plugin.