HomePhabricator

[explorer] Format askama HTML templates using djlint instead of prettier

Description

[explorer] Format askama HTML templates using djlint instead of prettier

Summary:
Currently, the HTML templates are very hard to work with as prettier's "html" formatter breaks the logic of askama macros / control flow.

By using "djlint" (from Django) instead of prettier, we get formatting that's much more readable, especially {% match %} blocks are now indented by their logical structure. We use the jinja profile as that one is extremely similar to askama.

There's some massaging applied still to make it more readable, but overall the formatter is doing a great job already.

One downside is that the principles behind HTML formatting of djlint differs quite a bit with prettiers, so we get a lot of unneeded style changes, but the advantages of having proper, consistent and automatic formatting are much greater

Test Plan:

  1. pip install djlint
  2. If wanted, run djlint ./explorer-server/templates --profile=jinja --reformat --custom-blocks=match,for --ignore-blocks=call --format-js --max-line-length=80 and double-check it outputs "0 files were updated."
  3. Run the explorer, check if each page is still rendered correctly (e.g. the tx 99d965ef70ac5c620906b72d7900721aea35295bf613aefe9f7ef91c83039a71)

Reviewers: #bitcoin_abc, PiRK

Reviewed By: #bitcoin_abc, PiRK

Subscribers: PiRK

Differential Revision: https://reviews.bitcoinabc.org/D16662

Details

Provenance
tobias_ruckAuthored on Aug 20 2024, 19:12
tobias_ruckPushed on Aug 20 2024, 19:16
Reviewer
Restricted Project
Differential Revision
D16662: [explorer] Format askama HTML templates using djlint instead of prettier
Parents
rABC465d676f8e34: [Automated] Update chainparams
Branches
Unknown
Tags
Unknown