title: How can I add a custom filter to my Twig templates inside of Slim?
body: <p>Using the example from <a href="http://twig.sensiolabs.org/doc/advanced.html#creating-an-extension" rel="noreferrer">http://twig.sensiolabs.org/doc/advanced.html#creating-an-extension</a>: within my main <code>Slim</code> file that creates the view:</p>
  
  <pre><code>$filter = new Twig_SimpleFilter( 'stripslashes', function ( $string ) { 
      return stripslashes( $string );
  });
  
  $loader = new \Twig_Loader_String();
  $twig = new Twig_Environment($loader);
  $twig-&gt;addFilter($filter);
  
  $app-&gt;view($twig);
  
  $app-&gt;view()-&gt;setData( array(
      'nav' =&gt; $nav,
      'sidenav' =&gt; $sidenav,
  ));
  </code></pre>
  
  <p>Results in: <code>Call to undefined method Twig_Environment::appendData()</code>.</p>
  
  <p>Tried in various ways such as this:</p>
  
  <pre><code>$app-&gt;view(new \Slim\Views\Twig());
  $app-&gt;view-&gt;parserExtensions = array(
      new \Slim\Views\TwigExtension(),
  );
  
  $app-&gt;view-&gt;addFilter($filter);
  </code></pre>
  
  <p>but I'm just not understanding how it's supposed to work. </p>