Exclude main content from spaceless

This commit is contained in:
Gabriel Augendre 2021-01-05 19:04:12 +01:00
parent bb1f2a7838
commit 06205dbaea
No known key found for this signature in database
GPG key ID: 1E693F4CE4AEE7B4
2 changed files with 4 additions and 9 deletions

View file

@ -1,7 +1,7 @@
{% load static compress %} {% load static compress %}
{% spaceless %}
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
{% spaceless %}
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
@ -35,12 +35,14 @@
<p>{{ blog_description }}</p> <p>{{ blog_description }}</p>
{% include "articles/snippets/navigation.html" %} {% include "articles/snippets/navigation.html" %}
</header> </header>
{% endspaceless %}
<main> <main>
{% block content %} {% block content %}
{% endblock %} {% endblock %}
</main> </main>
{% spaceless %}
<footer> <footer>
<hr> <hr>
<p> <p>
@ -64,5 +66,5 @@
{% endcompress %} {% endcompress %}
</body> </body>
{% endspaceless %}
</html> </html>
{% endspaceless %}

View file

@ -50,16 +50,9 @@ def _assert_article_is_rendered(item: Article, res):
content = res.content.decode("utf-8") content = res.content.decode("utf-8")
assert item.title in content assert item.title in content
html = item.get_formatted_content html = item.get_formatted_content
html = get_spaceless_html(html)
assert html in content assert html in content
def get_spaceless_html(html):
context = Context({})
html = Template("{% spaceless %}" + html + "{% endspaceless %}").render(context)
return html
@pytest.mark.django_db @pytest.mark.django_db
def test_anonymous_cant_access_draft_detail( def test_anonymous_cant_access_draft_detail(
client: Client, unpublished_article: Article client: Client, unpublished_article: Article