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.
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. 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.
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.
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. 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.