title: How do I return a twig rendered template as part of a JSON response?
body: <p>I want to return an HTML snippet as well as other values in a json string, here is what I have:</p>
  
  <pre><code>$html = $this-&gt;render('sometemplate.html.twig', array( 'somevar' =&gt; $somevar ) );
  $response = new Response(json_encode( array("html" =&gt; $html, "name" =&gt; "Joe Bloggs") ));
  $response-&gt;headers-&gt;set('Content-Type', 'application/json');
  return $response;
  </code></pre>
  
  <p>But all I get is <code>{"html":{"headers":{}}}</code>. Is there a way to just grab the rendered HTML?</p>