title: Symfony2 pass variable from controller to javascript
body: <p>I have this controller.php</p>
  
  <pre class="lang-php prettyprint-override"><code>    $repository = $this-&gt;getDoctrine()-&gt;getManager()-&gt;getRepository('TechappStatsBundle:ParentForm');
      $data = $repository-&gt;findBy(array(),array('id' =&gt; 'desc'),1,0); 
  
      $formulaire = new ParentForm();
  
      $parent= $this-&gt;get('form.factory')-&gt;create(new ParentFormType(),$formulaire);
  
      if ($parent-&gt;handleRequest($request)-&gt;isValid()) {
          $em = $this-&gt;getDoctrine()-&gt;getManager();
          $em-&gt;persist($formulaire);
          $em-&gt;flush();
      }
  
      return $this-&gt;render('TechappStatsBundle:Stats:index.html.twig',array("res" =&gt; $data,
          "parentform"=&gt;$parent-&gt;createView(),));
  </code></pre>
  
  <p>I want to check the variable <code>res</code> in my view with js if it is equals to a specific value or not but I don't know how to pass it.</p>