1

What is the difference between the following 2 template variable assignment?

{% set active_page = 'index.htm' %}
---vs---
{% set active_page = 'index.htm' -%}

1 Answer 1

1

The second one will remove the white space after it. As the document says:

You can also strip whitespace in templates by hand. If you add a minus sign (-) to the start or end of a block (e.g. a For tag), a comment, or a variable expression, the whitespaces before or after that block will be removed:

{% for item in seq -%}
    {{ item }}
{%- endfor %}

This will yield all elements without whitespace between them. If seq was a list of numbers from 1 to 9, the output would be 123456789.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! It is very difficult to search for these kind of things in Google directly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.