Skip to content

[BUG] [Formatter] Hyperscript newlines are not respected #1202

@savchenko

Description

@savchenko

System Info

  • OS: Debian 13
  • Python Version (python --version): Python 3.13.2
  • djLint Version (djlint --version): djlint, version 1.36.4
  • template language: Jinja2

Issue

Content of the Hyperscript attribute _ is always reduced to single line.

How To Reproduce

Try formatting this snippet:

<button class="whatever"
    hx-post="{{ url_for("some.path") }}"
    hx-headers='{
        "X-CSRFToken": "{{ csrf_token() }}"
    }'
    _="on htmx:afterRequest 
    if event.detail.xhr.status == 200 
        set me.disabled to true
    else
        set me.disabled to false">
    Refresh search index
</button>

Result:

<button class="whatever"
        hx-post="{{ url_for("some.path") }}"
        hx-headers='{ "X-CSRFToken": "{{ csrf_token() }}" }'
        _="on htmx:afterRequest if event.detail.xhr.status == 200 set me.disabled to true else set me.disabled to false">
    Refresh search index
</button>

I can understand the single-line hx-*, but joined _ is not great.
There can be more logic and having it all in single line makes code properly unreadable.

Notes

Might be related to #723

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions