title: How to create dynamic route with parameter in a JavaScript function?
body: <p>One of my route is defined like this:</p>
  
  <pre><code>society_mybundle_searchpage:
      pattern:  /search/cp/{cp}
      defaults: { _controller: SocietyMyBundle:Search:searchByCP }
  </code></pre>
  
  <p>So it needs one parameter: <code>{cp}</code>.</p>
  
  <p>Now I'd like to create a form with an input widget. So my code is like that:</p>
  
  <pre><code>  &lt;form onsubmit="return search();" action="#"&gt;
      {{ form_rest(form) }}
    &lt;/form&gt;
  </code></pre>
  
  <p>(Nothing specific, I let symfony do all the work for me). Note that this form calls a JS function: <code>search()</code>. So here's my code in twig:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  &lt;!--
  function verif_formulaire(){
      /* some code to get the value of the cp */
      ...
      /* then: */
      ss="{{ path('society_mybundle_searchpage', {'cp': '+cp+'}) }}";
      return true;
  }
  --&gt;
  &lt;/script&gt;
  </code></pre>
  
  <p>The output is:</p>
  
  <pre><code>function verif_formulaire(){
      ss="/symfony/web/app_dev.php/pizzas/search/cp/+tt+";
      return true;
  }
  </code></pre>
  
  <p>This is not the output I need. I want the output to be exactly like that this:</p>
  
  <pre><code>function verif_formulaire(){
      ss="/symfony/web/app_dev.php/pizzas/search/cp/"+tt+"/";
      return true;
  }
  </code></pre>
  
  <p>How shall I proceed?</p>