fabpot/Twig — Issue #539: Raw output not possible in some ternary statements
Author: jmikola
Created: 2011-11-28 16:38:45+00:00
State: open

According to the [Twig docs](http://twig.sensiolabs.org/doc/api.html#escaper-extension):

```jinja
{{ foo ? "Twig
" : "
Twig" }} {# won't be escaped #}

{% set text = "Twig
" %}
{{ foo ? text : "
Twig" }} {# will be escaped #}

{% set text = "Twig
" %}
{{ foo ? text|raw : "
Twig" }} {# won't be escaped #}

{% set text = "Twig
" %}
{{ foo ? text|escape : "
Twig" }} {# the result of the expression won't be escaped #}
```

However, I'm seeing:

```jinja
{% set foo = '

Twig

' %}

{% if true %}{{ foo|raw }}{% else %}{{ foo }}{% endif %} {# won't be escaped #}
{{ true ? foo|raw : foo }} {# will be escaped #}
{{ true ? foo|raw : 'string-literal' }} {# won't be escaped #}
```

Even though the ternary's else condition is never reached, it seems to affect the true condition's processing. This case is absent from the documentation example, which always used string literals in the else condition.