How to split long line in Django template?

送分小仙女□ 提交于 2019-12-04 16:56:14

问题


I have too long line in Django template

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

How can I split it?

Using \ or just splitting doesn't work.


回答1:


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 %}



回答2:


You can use 'word wrap' or 'soft wraps' feature of your text editor. In the PyCharm if you search by soft you will see:



来源:https://stackoverflow.com/questions/8077609/how-to-split-long-line-in-django-template

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!