Closed korverdev closed 6 months ago
While I understand and appreciate your request, I'm going to be very harsh and close it as WONTFIX. The goal of DjHTML has always been limited to indenting and not formatting templates. From the README:
DjHTML is an indenter and not a formatter: it will only add/remove whitespace at the beginning of lines
Makes total sense. Sorry I somehow overlooked that and thanks for the explanation.
Adding the following to .pre-commit-config.yaml
seems to be able to sort this out as well. I've tested on Ubuntu, Command Prompt, and PowerShell. I think it's supposed to work on MacOS too without installing anything extra.
- repo: local
hooks:
- id: template-spaces
name: template-spaces
entry: perl -pi -e "s/{%\s*/{% /g; s/\s*%}/ %}/g; s/{{\s*/{{ /g; s/\s*}}/ }}/g"
language: system
files: templates/.+\.(txt|html)$
This is more of a feature request, but I'd love if this project standardized spacing within tags as well. For example, the following is currently unchanged:
It would be great if this could be formatted automatically to mirror Django's examples: