cookiecutter-django icon indicating copy to clipboard operation
cookiecutter-django copied to clipboard

Linter/Formatter for Django templates

Open aleprovencio opened this issue 2 years ago • 6 comments

Description

I propose we add either djlint or djhtml as a local requirement and pre-commit hooks.

Rationale

I think this is a missing part of the tooling available for the cookiecutter-django ecosystem. What do you think?

aleprovencio avatar Aug 04 '22 14:08 aleprovencio

These 2 look really good! Thanks for the suggestion.

I'm not sure which one is better though. Here what I could gather:

  • Looks like they were started around the same time
  • Both seem quite active and well maintained.
  • djhtml seems a bit more focused on Django, while djlint seems a bit more general purpose (supporting other template languages like handlebars).
  • djhtml has more than double the amount of GitHub stars. That might be just down the lead maintainer being better at marketing, though.

I don't see a clear winner from the above, so I guess it would be down to trying each and see which one behaves better. One aspect I'm interested in is how fast they run on a relatively large project, autoformatter can be slow and when you need to run on each commit, execution time matters. Do you have some insights to provide on that front?

browniebroke avatar Aug 05 '22 10:08 browniebroke

Thanks for considering it!

From my experience I have only been using djlint with neovim, mostly working 'on demand' basis. I recently started to also include it in a pre-commit workflow, and so far its been just fine (project not as big though).

One thing to notice is that although they have some overlapping functionalities, djlint claims to be a linter/formatter while djhtml an indenter.

aleprovencio avatar Aug 05 '22 11:08 aleprovencio

Hi, I am just starting to contribute to open source and I think this can be a good issue for me. Can I take it? Looks like djlint will be used here and not djhtml

sikaili99 avatar Aug 24 '22 20:08 sikaili99

@sikaili99, how can I help support you in adding this? I'm new(er) to cookie-cutter, but if @aleprovencio or @browniebroke can point to the file(s) and process, I could write code this week and next with @sikaili99.

I'm guessing its more than adding 'djlint' or 'djhtml' to line 12 below in the code quality section of requirements.txt

Screen Shot 2022-09-07 at 7 27 54 PM

djlint or djhtml as a local requirement and pre-commit hooks

datatalking avatar Sep 08 '22 02:09 datatalking

@datatalking I haven't looked into this much, but I think after adding the package on line 12, there should be adding some configurations in the pre-commit config file!

sikaili99 avatar Sep 08 '22 07:09 sikaili99

that's correct, in addiction it might be a good idea to format/lint all template files so users won't get errors on a new project.

aleprovencio avatar Sep 08 '22 18:09 aleprovencio