title: Twig namespace class methods
body: <p>I'm attempting to transition a lightweight MVC framework to use <code>Twig</code> as a template engine instead of it just including <code>php</code> files in the controller. This would allow me to create multiple website layout folders under one core and allow clients to manipulate the templates.</p>
  
  <p>I've gotten Twig to work, but I have a problem with a namespace and it's classes. </p>
  
  <p>This framework uses it's own namespace in each <code>template.php</code> file, which gives access to a multitude of classes. One of them is a localization class, <code>Localize</code>, which has a method <code>string</code>. I would like to pass all strings in Twig templates through the <code>Localize::string()</code> method, but how can I do this?</p>
  
  <p>In the controller I have:</p>
  
  <pre><code>$loader = new \Twig_Loader_Filesystem([$path]);
  $twig = new \Twig_Environment($loader);
  echo $twig-&gt;render($file, $data);
  </code></pre>
  
  <p>I tried to use:</p>
  
  <pre><code>$loader-&gt;addPath($path, 'Namespace');
  </code></pre>
  
  <p>With no luck. In the template:</p>
  
  <pre><code>{{ Localize.string('string') }} 
  </code></pre>
  
  <p>The method is supposed to return the string or a translation but returns nothing meaning it does not work. Can I somehow add all templates to a namespace as I would</p>
  
  <pre><code>&lt;?php namespace Namespace; ?&gt;
  </code></pre>
  
  <p>and have access to Localize::string() ?</p>