Djade: a template formatter

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

And the repo:

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

8 Likes

Very cool, thank you Adam!

2 Likes

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!

2 Likes

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!

2 Likes

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.


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

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.

2 Likes

Done!

(Not without a mild heart attack when I saw the proposal in this comment)

3 Likes