Answer the question
In order to leave comments, you need to log in
Removing empty line breaks from page code
Good afternoon!
There is a django template, there are a bunch of different ones
. So, this construction gives two empty newlines before and after {{ el }}, the question is: How to avoid this without resorting to the {% spaceless %} tag?
Thank you!
{% if ... %}
{% for el in list %}
{{ el }}
{% endfor %}
{% endif %}
Answer the question
In order to leave comments, you need to log in
Normally, no way. Place tags on one line. You can cut out the regexp in the middleware, but this evil is already some kind, worse than the spaceless tag. See code.djangoproject.com/ticket/2594
You can also use Jinja2 instead of django templates if empty lines are very annoying, or you can patch django (or fake patch only the right places) with a patch from the ticket. Or score.
I remembered about solutions for nginx, but it needs to be rebuilt with the necessary parameters ... Zhzhzhopa))
Why is jinja2 better? Does she cut herself?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question