canonical / ubuntu.com

The official website for the Ubuntu operating system
https://ubuntu.com
Other
185 stars 189 forks source link

Djlint is enforcing whitespace in meta fields which could be improved #13994

Closed anthonydillon closed 3 days ago

anthonydillon commented 1 week ago

I suppose this is enforced by the formatter that blocks are not in single line, but in cases like this one, when it's only a class name, or above, where it's a copydocs link it makes them multiline in resulting HTML.

image

It's not invalid, and probably will work fine in most cases, but it would be better to make it not have unnecessary line breaks or whitespace inside these values.

Maybe values like these should be variables in the template, not blocks.


After a quick investigation, I believe the true fix is to update the template-finder project to configure Jinja to trim_blocks, the first newline after a template tag is removed automatically. Then we can use the whitespace control to trim further whitespace using {%- block -%}.

anthonydillon commented 3 days ago

@lizzochek was this fixed as part of some PR?