Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

New line in django templates

Tags:

django

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

like image 794
Joel Avatar asked Nov 29 '25 01:11

Joel


1 Answers

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!

like image 176
Timmy O'Mahony Avatar answered Nov 30 '25 14:11

Timmy O'Mahony



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!