Skip to content

[FEATURE] #1463

@brasmussen117

Description

@brasmussen117

Feature Request

Add support for Google Style line breaks for attributes in HTML tags

It would be great if this package could use Google Style Guidelines for breaking lines with regards to attributes.

I believe this issue is a misunderstanding of how djLint is handling line breaks for HTML tag attributes. In their examples, the <a> tag is being broken up, but the first attribute stays where it is, and the following attributes are lined up underneath. Coming from a Python environment, this kind of line breaking may not be super intuitive.

The Google Style breaks put the first and all subsequent attributes on new lines. It also moves the ending > on its own line, dedented to the level of the opening <.

Granted, this is just an opinion, but the Google Style makes sense for several reasons:

  • The indent for attributes is always the same, whether the tag is <a> or <figcaption>
  • You're likely to be leaving more space for the contents of the attribute, and for Django templates, this is clutch
  • It matches how Python formatters, like Black, break long lines

My team has adopted Black as our automatic formatter for Python code, and we were hoping we could use this package in the same way for our templates. Unfortunately, this particular quirk is kind of a deal breaker.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions