fabpot/Twig — Issue #646: Countable property lost on for... if
Author: bistory
Created: 2012-02-23 20:53:32+00:00
State: open

Hi !

The countable property is lost when using for... if; example :

I set a variable with :

```php
$test = array(1, 2, 4, 6, 7);
```

If using Twig, I make that :

```html
{% for lp in lp_test if lp < 5 %}
{{ loop.length }} {{ loop.first }}{{ loop.last }}
{% endfor %}
```

It produces :

```html
5 1
5
5
5
5 1
```

Which is the expected result

But if I add a condition like that :

```html
{% for lp in lp_test if lp < 5 %}
{{ loop.length }} {{ loop.first }}{{ loop.last }}
{% endfor %}
```

And the result is not exactly the one expected :
```html
1

```
The countable property disappeared and all his useful features like loop.last...

Thanks for your help !