fabpot/Twig — Issue #564: Strange behavior with spaceless and comments
Author: hhamon
Created: 2011-12-21 13:04:16+00:00
State: open

Hi Fabien,

Don't know if it's a bug or not but the minus character does not seem to work well when there is a Twig comment in the code. Look at the following example:

{% block title -%}

{# some commented line of code #}

My super title...

{%- endblock %}

In this code, I want to trim the value on the left and on the right. The value is well trimmed on the right but not on the left. In fact the value is trimmed until the beginning of the comment. So instead of having a one line value, I get the following result:

My super title...

There is an extra line feed before the text, which is the line feed between the end of the comment and the beginning of the text.

My question is, is it expected or not that a comment is not considered as a blank string?