# Djade: a template formatter

**URL:** <https://forum.djangoproject.com/t/djade-a-template-formatter/35138>\
**Category:** Show & Tell\
**Created:** [September 26, 2024, 2:47pm UTC](https://forum.djangoproject.com/t/djade-a-template-formatter/35138 "2024-09-26T14:47:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![adamchainz](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/adamchainz/32/26_2.png) [@adamchainz](https://forum.djangoproject.com/u/adamchainz)\
**Post date:** [September 26, 2024, 2:47pm UTC](https://forum.djangoproject.com/t/djade-a-template-formatter/35138/1 "2024-09-26T14:47:03Z")

</div>

My new project, Djade, is a formatter for Django templates. Heres the introductory post:

> **[Django: Introducing Djade, a template formatter - Adam Johnson](https://adamj.eu/tech/2024/09/26/django-introducing-djade/)**
>
> Happy DjangoCon US 2024 to you. Whilst I am not there, I have adopted the spirit of the season and got to work hacking together a new tool.

And the repo:

> **[GitHub - adamchainz/djade: A Django template formatter.](https://github.com/adamchainz/djade)**
>
> A Django template formatter.

Please check it out and let me know what you think!

---

<div class="post-metadata">

**Author:** ![CodenameTim](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/codenametim/32/31507_2.png) [@CodenameTim](https://forum.djangoproject.com/u/CodenameTim)\
**Post date:** [September 29, 2024, 1:55pm UTC](https://forum.djangoproject.com/t/djade-a-template-formatter/35138/2 "2024-09-29T13:55:09Z")

</div>

Very cool, thank you Adam!

---

<div class="post-metadata">

**Author:** ![jeff](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/jeff/32/55_2.png) [@jeff](https://forum.djangoproject.com/u/jeff)\
**Post date:** [October 1, 2024, 1:29pm UTC](https://forum.djangoproject.com/t/djade-a-template-formatter/35138/3 "2024-10-01T13:29:48Z")

</div>

I’m two projects into using djade and I think it’s great. I have told a few people that it’s “Black for Django templates” but it is not “Black for HTML” which I think frames it in the right light in case people are expecting too much.

I like \>90% of what it’s doing, which is similar to how I felt when Black came out.

Those nitpicks:

- I prefer `endblock` never drop the variable name even if they are on the same line. (I do subblocks sometimes and this already annoyed me.)
- I prefer `load` lines remain on separate lines. This makes diffs more readable. (Yes, I prefer this with my import-statement too because I spend a lot of time reading pull requests)

All-in-all, I think it’s a very promising tool. Nice work!

---

<div class="post-metadata">

**Author:** ![nessita](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/nessita/32/12194_2.png) [@nessita](https://forum.djangoproject.com/u/nessita)\
**Post date:** [October 1, 2024, 2:04pm UTC](https://forum.djangoproject.com/t/djade-a-template-formatter/35138/4 "2024-10-01T14:04:58Z")

</div>

Amazing tool!

For me, multiple `load` entries in the same line is a no no, just like with Python. You would not do this!

`import csv, collections`

In fact, I absolutely agree with you Adam on:

> My one preference opposed to the proposal is with `{% load %}`. I prefer multiple alphabetically sorted `{% load %}` tags. This style leads to fewer merge conflicts and keeps `git blame` accurate. I similarly prefer one-import-per-line in Python code and have seen fewer conflicts since adopting this style.

I think I missed that thread and wasn’t able to share my opinion in time. Sorry about that!

---

<div class="post-metadata">

**Author:** ![adamchainz](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/adamchainz/32/26_2.png) [@adamchainz](https://forum.djangoproject.com/u/adamchainz)\
**Post date:** [October 1, 2024, 2:27pm UTC](https://forum.djangoproject.com/t/djade-a-template-formatter/35138/5 "2024-10-01T14:27:42Z")

</div>

> [@jeff](#):
>
> I prefer `endblock` never drop the variable name even if they are on the same line. (I do subblocks sometimes and this already annoyed me.)

Yeah, I may have overstepped there. Is the issue because you have multiple blocks on the same line? Perhaps the style could be “drop the label when there’s one block on a single line, add the labels when there are multiple”? Probably best to continue the discussion an issue.

* * *

> [@jeff](#):
>
> I prefer `load` lines remain on separate lines. This makes diffs more readable. (Yes, I prefer this with my import-statement too because I spend a lot of time reading pull requests)

> [@nessita](#):
>
> In fact, I absolutely agree with you Adam on:

Can you both +1 on the relevant issues, just so I can keep track of the weight of opinions?

> <https://github.com/adamchainz/djade/issues/33>
>
> \### Description
> 
> First of all, thank you for building this!
> 
> Are you intereste…d in adding any configuration options?
> 
> I'm currently working on a project where most templates pull in a lot of tags. Many of those templates use a single load line, and the list is easily off the side of your screen. I'm moving the project to one tag per line to try and get a handle on the situation, but it's also my preference for ease of review.
> 
> Would you consider adding a config option to split or combine load lines?

So far no one has really said “combined load lines are better”, I just want to have more evidence I can point to when implementing the one-per-line style.

---

<div class="post-metadata">

**Author:** ![nessita](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/nessita/32/12194_2.png) [@nessita](https://forum.djangoproject.com/u/nessita)\
**Post date:** [October 1, 2024, 2:41pm UTC](https://forum.djangoproject.com/t/djade-a-template-formatter/35138/6 "2024-10-01T14:41:01Z")

</div>

> [@adamchainz](#):
>
> Can you both +1 on the relevant issues, just so I can keep track of the weight of opinions?

Done!

(Not without a mild heart attack when I saw the proposal in [this comment](https://github.com/adamchainz/djade/issues/33#issuecomment-2367855533))
