le Pusscat
le Pusscat

Reputation: 49

What is the hyphen for, apart from trimming whitespace?

I understand using

{{-          remove leading spaces -}}

for trimming whitespace, but in the example below, and that I've seen loads, what is the point?

{%- if true -%}

or

{%- endfor %}

What purpose does it serve in a control statement? I can find nothing in the documentation about this specifically, but if there is something, please, point me in the right direction!

Upvotes: 0

Views: 53

Answers (1)

DarkBee
DarkBee

Reputation: 15643

It applies to the full block,

{% for i in 1..10 %}
        {{ i }}
        
{% endfor %}

{%- for i in 1..10 -%}
        {{ i }}
        
{%- endfor -%}

output

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

12345678910

demo

Upvotes: 2

Related Questions