Joel
Joel

Reputation: 6107

New line in django templates

When I use the following:

<html>
{% block head %}
<title>Hello</title>
{% endblock %}

The output in the HTML document is:

<html>
--- empty line ---
<title>Hello</title>

How can I avoid this empty line? I can use:

<html>
{% block head %}<title>Hello</title>
{% endblock %}

but that is ugly...

Thanks,

Joel

Upvotes: 3

Views: 3701

Answers (2)

Timmy O&#39;Mahony
Timmy O&#39;Mahony

Reputation: 53998

If you are concerned about saving space/kbytes you can use the {% spaceless %} template tag to get get rid of all the empty spaces between html tags. This is generally good practice. So put {% spaceless %} at the very top of your base.html and {% endspaceless %} at the very end

If you are worried about the asthetics of your code, there's not much you can do!

Upvotes: 5

Related Questions