Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to split long line in Django template?

I have a line in my Django template that is too long:

 {% for some_item, some_another_item, again_some_another_item_with_long_name in items %}

Is there a way to split it so that it looks nicer in the source code?

Using \ or just splitting doesn't work.

like image 878
varepsilon Avatar asked Nov 10 '11 09:11

varepsilon


1 Answers

If you really want to keep those nasty long names, what I would do is:

{% for a, b, c in items %}
    {% with a as some_item %}
    {% with b as some_another_item %}
    {% with c as again_some_another_item_with_long_name %}
        bla bla bla ..
    {% endwith %}
    {% endwith %}
    {% endwith %}
{% endfor %}
like image 98
juliomalegria Avatar answered Oct 24 '22 00:10

juliomalegria