Skip to content

[BUG] [Linter] False postitive on T002 when tag is embedded in an HTML attribute #687

@thirdjal

Description

@thirdjal

System Info

  • OS: macOS 13.4
  • Python Version: 3.10.11
  • djLint Version 1.30.2
  • template language: django

Issue

I've run into an issue where a number of my templates are reporting Linting error T002: Double quotes should be used in tags. This rule conflicts with H008: Attributes should be double quoted.

This issue comes up when using i18n translation tags inside attributes of an element, such as a tooltip, image alt-text, or labels for assistive services. These should not be considered a violation of rule T002.

How To Reproduce

Examples with false flags
Alt-text on an image
<img src="https://picsum.photos/200/100" alt="{% translate 'A very nice image' %}">

A Bootstrap close button
<button type="button" class="btn-close" aria-label="{% translate 'Close' %}"></button>

Contents of .djlintrc/pyproject.toml [tool.djlint]

[tool.djlint]
blank_line_after_tag="load,extends,endblock"
indent=2
max_line_length=120
profile="django"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions