Skip to content

Commit 7be1db9

Browse files
committed
Avoid final newlines in templatetag templates
Don't need no noise.
1 parent 9238525 commit 7be1db9

File tree

6 files changed

+15
-5
lines changed

6 files changed

+15
-5
lines changed

.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,9 @@ trim_trailing_whitespace = true
1313
indent_style = space
1414
indent_size = 4
1515

16+
[src/django_otp_webauthn/templates/*.html]
17+
# Final newlines don't have to end up in the HTML output of end users
18+
insert_final_newline = false
19+
1620
[*.md]
1721
trim_trailing_whitespace = false

.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ repos:
66
hooks:
77
- id: trailing-whitespace
88
- id: end-of-file-fixer
9+
exclude: |
10+
(?x)^(
11+
src/django_otp_webauthn/templates/django_otp_webauthn/auth_scripts.html|
12+
src/django_otp_webauthn/templates/django_otp_webauthn/register_scripts.html|
13+
src/django_otp_webauthn/templates/django_otp_webauthn/sync_signals_scripts.html
14+
)$
915
- id: check-added-large-files
1016
- id: check-case-conflict
1117
- id: check-json

src/django_otp_webauthn/templates/django_otp_webauthn/auth_scripts.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
{{ configuration|json_script:"otp_webauthn_config"}}
33
<script async defer src="{% url "otp_webauthn:js-i18n-catalog" %}"></script>
44
<script type="module" src="{% static "django_otp_webauthn/otp_webauthn_auth.js" %}"></script>
5-
{% endspaceless %}
5+
{% endspaceless %}

src/django_otp_webauthn/templates/django_otp_webauthn/register_scripts.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
{{ configuration|json_script:"otp_webauthn_config"}}
33
<script async defer src="{% url "otp_webauthn:js-i18n-catalog" %}"></script>
44
<script type="module" src="{% static "django_otp_webauthn/otp_webauthn_register.js" %}"></script>
5-
{% endspaceless %}
5+
{% endspaceless %}

src/django_otp_webauthn/templates/django_otp_webauthn/sync_signals_scripts.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
{{ configuration|json_script:"otp_webauthn_sync_signals_config"}}
44
<script async type="module" src="{% static "django_otp_webauthn/otp_webauthn_sync_signals.js" %}"></script>
55
{% endif %}
6-
{% endspaceless %}
6+
{% endspaceless %}

tests/unit/test_templatetags.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def test_render_otp_webauthn_sync_signals_scripts__not_authenticated(client):
135135
rendered = template.render(context)
136136
# User is not authenticated, so we stay silent and render
137137
# nothing - even though the sync needed flag is set.
138-
assert rendered.strip() == ""
138+
assert rendered == ""
139139

140140

141141
@pytest.mark.django_db
@@ -190,4 +190,4 @@ def test_render_otp_webauthn_sync_signals_scripts__authenticated(
190190

191191
rendered = template.render(context)
192192
# We did not set the sync needed flag, so we stay silent and render nothing
193-
assert rendered.strip() == ""
193+
assert rendered == ""

0 commit comments

Comments
 (0)