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.1
  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.1
  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.1.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.1.tar.gz.

File metadata

File hashes

Hashes for django_no_multiline_template_comment-0.0.1.tar.gz
Algorithm Hash digest
SHA256 3c79f90c3996bba6332dc43410128315c9418535b196ba972bc6338af69e99df
MD5 9a9434b88214abe31c90b5a928275c83
BLAKE2b-256 1197a9b6469c0d55e4ed1365f58bc735b02c1c9ee422ad235b4b044de40a2fa4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_no_multiline_template_comment-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 76943da7ca9741bf03b5d325e007efefa6e4588c263f405c6a3f132f7e8fe8fe
MD5 b21b32b250af0e8251a6cac5168b41c7
BLAKE2b-256 9397c98c6a920a88128a3f03967bf850bd55f41f67f29f94cb543f08b4fd9245

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