]> git.immae.eu Git - github/wallabag/wallabag.git/blame - vendor/twig/twig/doc/tags/spaceless.rst
twig implementation
[github/wallabag/wallabag.git] / vendor / twig / twig / doc / tags / spaceless.rst
CommitLineData
4f5b44bd
NL
1``spaceless``
2=============
3
4Use the ``spaceless`` tag to remove whitespace *between HTML tags*, not
5whitespace within HTML tags or whitespace in plain text:
6
7.. code-block:: jinja
8
9 {% spaceless %}
10 <div>
11 <strong>foo</strong>
12 </div>
13 {% endspaceless %}
14
15 {# output will be <div><strong>foo</strong></div> #}
16
17This tag is not meant to "optimize" the size of the generated HTML content but
18merely to avoid extra whitespace between HTML tags to avoid browser rendering
19quirks under some circumstances.
20
21.. tip::
22
23 If you want to optimize the size of the generated HTML content, gzip
24 compress the output instead.
25
26.. tip::
27
28 If you want to create a tag that actually removes all extra whitespace in
29 an HTML string, be warned that this is not as easy as it seems to be
30 (think of ``textarea`` or ``pre`` tags for instance). Using a third-party
31 library like Tidy is probably a better idea.
32
33.. tip::
34
35 For more information on whitespace control, read the
36 :doc:`dedicated<../templates>` section of the documentation and learn how
37 you can also use the whitespace control modifier on your tags.