nortmas
9/27/2017 - 4:24 PM

Whitespace

// To remove both leading and trailing whitespace on either side of a Twig code block

<span>
  {%- for item in items -%}
    {{ item.content }}
  {%- endfor -%}
</span>

// Output:

<span>example</span>
// This tag will remove all whitespace between HTML tags, excluding spaces inside blocks of text or space inside an HTML tag.

{% spaceless %}
<div class="example code">
    <strong>{{ prints_out_the_word_example }}</strong>
</div>
{% endspaceless %}

// Output:

<div class="example code"><strong>example</strong></div>