title: Twig: filter in an if condition
body: <p>I want to use an filter in an if condition in Twig. The reason for this is a Symfony2 attribute, which I can't compare directly, I have to change it beforehand. I have started with this code:</p>
  
  <pre><code>{% if app.request.attributes.get('_controller')|split('::')|first == 'some\controller\name' %}
    do something
  {% endif %}
  </code></pre>
  
  <p>Unfortunately this does not function. So I thought I would use set before the comparison:</p>
  
  <pre><code>{% set controller = app.request.attributes.get('_controller')|split('::')|first %}
  {% if controller == 'some\controller\name' %}
    do something
  {% endif %}
  {{ controller }} {# would print 'some\controller\name' #}
  </code></pre>
  
  <p>Guess what? "do something" is not printed, even if the variable <em>controller</em> now exists and has the value I compare it with. What am I doing wrong?</p>