Closed norkunas closed 1 year ago
Is there a non-aesthetic reason for controlling whitespace?
saving bytes :)
As a workaround you can use the spaceless
filter:
{% apply spaceless %}
<twig:Component>
<div>Some text</div>
</twig:Component>
{% endapply %}
saving bytes :)
I don't think it's an issue if your web server is using content encoding like gzip/brotli.
From https://symfony.com/blog/better-white-space-control-in-twig-templates:
Controlling white spaces is very important when using Twig to generate contents like YAML, text emails or any other format where the white spaces are significant.
In contrast, when generating HTML contents, most of the times you should ignore this feature, because the HTML contents are minified and compressed before sending them to the users, so trying to generate perfectly aligned HTML code is just a waste of time.
What about emails? My point is not to align or something but squeeze as possible :)
Yeah, not sure about emails. I just remember reading that blog post and never bothering with spaceless in HTML again.
My thinking is this:
{% apply spaceless %}
<twig:Component>
<div>Some text</div>
</twig:Component>
{% endapply %}
I'm not excited about adding a <-twig:Component->
type of thing :)
I'm not excited about adding a
<-twig:Component->
type of thing :)
Me too :) strange that when {% apply spaceless %}
is used in base template it sometimes still not enough and needs to be done in nested templates
With the old syntax like
{{- component() -%}
and{%- component .. -%}
it is possible to control whitespace but with the html syntax I don't see a way.What are the options? :)