I have this code in index.twig
(snippet formatted exactly as shown):
<div style="width: 12.5%; float: left; text-align: left; padding-right: 7.5px; padding-top: 5px;">{% include "_nav.twig" %}</div>
And this is my _nav.twig
(snippet also formatted exactly as shown):
<nav>
<ol class="linkSection">
<li><a href="index.php">Index</a></li>
<li id="nav-expand-collapse" class="isCollapsed"><a href="#">Expand All</a></li>
</ol>
<ol class="linkSection">
<li class="h2">Research</li>
<li><a href="index.php?p=research_intro">Introduction</a></li>
<li><a href="index.php?p=research_intro">Foo</a></li>
<li><a href="index.php?p=research_intro">Bar</a></li>
<li><a href="index.php?p=research_intro">Spam</a></li>
<li><a href="index.php?p=research_intro">Eggs</a></li>
</ol>
</nav>
This is the expected output (notice the lack of spaces between the heading and the Index link:
What happens is that Twig would include unnecessary whitespace like so:
This is what I see in the Chrome Development Console (Notice the ""
):
I have tried {%- include -%}
, {% spaceless %}
around the <div>
and {% include|trim(" ")
, but none of them succeeds at getting rid of the whitespace. How can I get rid of these whitespaces?
All files are encoded in UTF-8. The problem seems to be gone when I encode as UTF-8 without BOM.