Skip to main content

Reject multi-line Django '{# #}' template comments (a wrapped '{# #}' renders as visible text).

Project description

django-no-multiline-template-comment

PyPI version PRs Welcome

django-no-multiline-template-comment rejects multi-line Django {# … #} template comments.

Why

Django's {# #} comment is single-line only. A {# whose closing #} is on a later line does not comment the following lines — they render as visible text on the page. Use {% comment %}…{% endcomment %} for anything that may wrap. This hook catches the mistake in CI.

{# ✗ broken: this comment
   spans two lines, so everything here leaks onto the page as text #}

{# ✓ fixed: single-line comment #}
{% comment %}
   ...or {% comment %} for anything that may wrap.
{% endcomment %}

Installation

- repo: https://github.com/Pierre-Sassoulas/django-no-multiline-template-comment/
  rev: v0.0.2
  hooks:
    - id: django-no-multiline-template-comment

Autofix

Pass --fix to rewrite offending comments to {% comment %}…{% endcomment %} in place (valid single-line comments and unterminated {# are left untouched). As with other fixer hooks, a rewritten file fails the run so you review and re-stage it.

- repo: https://github.com/Pierre-Sassoulas/django-no-multiline-template-comment/
  rev: v0.0.2
  hooks:
    - id: django-no-multiline-template-comment
      args: [--fix]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_no_multiline_template_comment-0.0.2.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file django_no_multiline_template_comment-0.0.2.tar.gz.

File metadata

File hashes

Hashes for django_no_multiline_template_comment-0.0.2.tar.gz
Algorithm Hash digest
SHA256 720ed008161da33f0e1e3b3e73df5fe05e594dc250df4000eb24552ecdd0ef7b
MD5 258309275189b11401ac3af93ca5b78d
BLAKE2b-256 3b5bc3523914dfdeb6d0204b53fff0e60a89534c61fc7583a39b8d970a96ff4a

See more details on using hashes here.

File details

Details for the file django_no_multiline_template_comment-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for django_no_multiline_template_comment-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c13b6bbac5b77a87d119f5324a21f920fcd8c6f9b1bcb61b0c45c4f6a1d8cc98
MD5 59763ef67ec490d5fd04c9a6da067121
BLAKE2b-256 8f8ea975846b0153cebd61f51a02be5e179aa68cee65d0a66b1b57e64d26d0bd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page