title: How to render TWIG output to a variable for later use (symfony2)?
body: <p>Instead of doing this rendering of each slide in my TWIG like this (see line 6):</p>
  
  <pre><code>{# loop out the slides #}
  {% for c in contents %}
      {% set i=i+1 %} {# increase slide number #}
      &lt;div id="slide{{ i }}" class="slide" style="z-index:{{ i }};"&gt;
          {# the slide itself, rendered by it's own template #}
          {% include 'BizTVArchiveBundle:ContentTemplate:'~c.template~'/view.html.twig' with {'contents': c, 'ordernumber': i} %} 
      &lt;/div&gt;
  {% endfor %}
  </code></pre>
  
  <p>...Instead I would like to keep all of that logic in the controller, to just deliver to the view an array of ready slides. How can I do something like this (see line 9):</p>
  
  <pre><code>    //do stuff...
      foreach ($container-&gt;getContent() as $c) {
                  $content[$i]['title'] = $c-&gt;getTitle();
                  $content[$i]['sort'] = $c-&gt;getSortOrder();
                  $content[$i]['data'] = $c-&gt;getData();
                  $content[$i]['template'] = $c-&gt;getTemplate()-&gt;getId();
                  $content[$i]['duration'] = $this-&gt;extract_seconds($c); 
  
                  $content[$i]['html'] = $this-&gt;render('BizTVArchiveBundle:ContentTemplate:'.$content[$i]['template'].'/view.html.twig', array(
                      'contents'=&gt; $content[$i],
                      'ordernumber' =&gt; 99,
                  ));
      }
  </code></pre>
  
  <p>All it gives me at the moment (the contents of $content[$i]['html']) is </p>
  
  <pre><code>{"headers":{}}
  </code></pre>