Add despacing to DTL to enable removal of blank lines and floating bits of text in generated HTML
- Dominant language
- No language data
- Stars
- 188
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Description
### Code of Conduct
- [x] I agree to follow Django's Code of Conduct
### Feature Description
Add two regular expressions to DTL's core loader to enable removing excess whitespace by using delimiters like `{#-` and `-#}`. These will remove excessive blank lines and floating text from generated HTML.
### Problem
HTML generated by DTL is, um, not beautiful or even okay looking: it often has lots and lots of blank lines and bits of text floating in space.
I know not everyone does a view-source, but I do. I also want to add lots of comments to my DTL templates without adding lots of blank lines to the generated HTML.
### Request or proposal
proposal
### Additional Details
For a more detailed description, see [django-despacer](https://pypi.org/project/django-despacer/).
I'm a frugal pragmatic perfectionist (with deadlines).
As a perfectionist, I'm horrified by the HTML generated by DTL: so many empty lines and bits of text floating in space. Being pragmatic, I accept that perfect whitespace control that generates perfectly indented HTML is unrealistic; so I'll settle for merely better looking HTML. Being frugal, I won't repeatedly pay a price for it (on every request) but I'm willing to pay just once (at template load time).
I'm pretty sure this won't break existing templates. I don't believe a `-` immediately after an opening delimiter or before a closing delimiter is currently valid. So, backward compatibility should be preserved.
### Implementation Suggestions
For demonstrating and testing the idea, I have implemented it as a package on PyPI: [django-despacer](https://pypi.org/project/django-despacer/). It works on my machine 😄.
Rather than it remaining a package, I'm hoping it can be included in core so it's awkward setup (requiring configuration of "loaders") is not necessary.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reviewing the django-despacer package linked in the proposal, then inspect Django's DTL core loader and how template delimiters are parsed. The work is done when equivalent `{#-` and `-#}` whitespace control is supported in core without breaking existing templates, with tests covering blank lines and floating text.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- django, python
- Domain
- backend, web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100