如何在Django模板中分割长行? [英] How to split long line in Django template?
本文介绍了如何在Django模板中分割长行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Django模板中有太长的线条
I have too long line in Django template
{% for some_item, some_another_item, again_some_another_item_with_long_name in items %}
如何拆分?
使用 \
或只是拆分不起作用。
Using \
or just splitting doesn't work.
推荐答案
如果你真的想保留那些讨厌的长名字,我会做的是:
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 %}
这篇关于如何在Django模板中分割长行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文