title: How to return Javascript in Symfony2?
body: <p>Like on Ruby on Rails, you can return Javascript with some prerendering to dynamically update the client site through AJAX. </p>
  
  <p>How do you return Javascript when calling some routes in Symfony2?</p>
  
  <p>For example, when calling <code>updateItemAppearanceAction</code> through <code>\item\{itemId}\update_appearance</code>, return Javascript file <code>updateItemAppearance.js.twig</code>, with <code>array("item"-&gt;$item)</code>?</p>
  
  <p>Thank you very much!</p>