title: Using "path" and "asset" for non-template data
body: <p>When creating templates with Twig, it's easy to use the <code>path</code> and <code>asset</code> functions.</p>
  
  <pre><code>&lt;a href="{{ path('my_route') }}"&gt;&lt;img src="{{ asset('bundles/acmedemo/my_image.png') }}" /&gt;&lt;/a&gt;
  </code></pre>
  
  <p>However, some of my data come from non-twig files or from database. What would be the right way to address these functions from there?</p>
  
  <p>So far, I'm using regex replace (<code>preg_replace_callback</code>) for the path function. But isn't there a nicer way?</p>