title: Javascript string parsing change slash with space with no reason
body: <p>I'm generating action buttons in my Ajax Datatable with routes coming from a symfony app, and displayed with Twig in my javascript function.</p>
  
  <p>Here is the javascript function :</p>
  
  <pre><code>{   data: "id", 
                  render:    function ( data, type, full, meta ) {
                      var duplicate   = "{{ path('duplicate_of', { 'id': 'elementid' }) }}";
                      var deleteof    = "{{ path('delete_of'   , { 'id': 'elementid' }) }}";
                      var update      = "{{ path('updt_of'     , { 'id': 'elementid' }) }}";
                      var detail      = "{{ path('detail_of'   , { 'id': 'elementid' }) }}";
                      var exportof    = "{{ path('export_of'   , { 'id': 'elementid' }) }}";
  
                      console.log(detail);
                      console.log(data);
  
      return "&lt;a class='pr5' title='Détail'        onClick='"+detail.replace("elementid", data)        +"'&gt;&lt;i class='fa fa-search' aria-hidden='true'&gt;&lt;/i&gt;&lt;/a&gt;"+
             "&lt;a class='pr5' title='Dupliquer'     href='"+duplicate   .replace("elementid", data)     +"'&gt;&lt;i class='fa fa-files-o' aria-hidden='true'&gt;&lt;/i&gt;&lt;/a&gt;"+
             "&lt;a class='pr5' title='Exporter'      href='"+exportof    .replace("elementid", data)     +"'&gt;&lt;i class='fa fa-file-excel-o' aria-hidden='true'&gt;&lt;/i&gt;&lt;/a&gt;"+
             "&lt;a class='pr10' title='Modifier'     href='"+update      .replace("elementid", data)     +"'&gt;&lt;i class='fa fa-pencil' aria-hidden='true'&gt;&lt;/i&gt;&lt;/a&gt;"+
             "&lt;a class='pr5 red' title='Supprimer' href='"+deleteof    .replace("elementid", data)     +"'&gt;&lt;i class='fa fa-times' aria-hidden='true'&gt;&lt;/i&gt;&lt;/a&gt;"
             ; 
  
                  }
  }
  </code></pre>
  
  <p>The javascript generated is as followed :</p>
  
  <pre><code>        {   data: "id", 
              render:    function ( data, type, full, meta ) {
                  var duplicate   = "/backend/web/app_dev.php/fr/of/elementid/duplicate";
                  var deleteof    = "/backend/web/app_dev.php/fr/of/elementid/delete";
                  var update      = "/backend/web/app_dev.php/fr/of/elementid/update";
                  var detail      = "/backend/web/app_dev.php/fr/of/elementid/detail";
                  var exportof    = "/backend/web/app_dev.php/fr/of/elementid/export";
  
                  console.log(detail);
                  detail = "openModal('"+detail+"');";
                  console.log(detail);
  
  return "&lt;a class='pr5' title='Détail'        onClick='"+detail.replace("elementid", data).replace(" ", "/")   +"'&gt;&lt;i class='fa fa-search' aria-hidden='true'&gt;&lt;/i&gt;&lt;/a&gt;"+
         "&lt;a class='pr5' title='Dupliquer'     href='"+duplicate   .replace("elementid", data)     +"'&gt;&lt;i class='fa fa-files-o' aria-hidden='true'&gt;&lt;/i&gt;&lt;/a&gt;"+
         "&lt;a class='pr5' title='Exporter'      href='"+exportof    .replace("elementid", data)     +"'&gt;&lt;i class='fa fa-file-excel-o' aria-hidden='true'&gt;&lt;/i&gt;&lt;/a&gt;"+
         "&lt;a class='pr10' title='Modifier'     href='"+update      .replace("elementid", data)     +"'&gt;&lt;i class='fa fa-pencil' aria-hidden='true'&gt;&lt;/i&gt;&lt;/a&gt;"+
         "&lt;a class='pr5 red' title='Supprimer' href='"+deleteof    .replace("elementid", data)     +"'&gt;&lt;i class='fa fa-times' aria-hidden='true'&gt;&lt;/i&gt;&lt;/a&gt;"
         ; 
  
              }
          }
  </code></pre>
  
  <p>The HTML code generated looks like this when I copy/paste in Stackoverflow :</p>
  
  <pre><code>&lt;td&gt;
      &lt;a class="pr5" title="Détail" onclick="openModal(" backend="" web="" app_dev.php="" fr="" of="" 39="" detail');'=""&gt;
          &lt;i class="fa fa-search" aria-hidden="true"&gt;&lt;/i&gt;
      &lt;/a&gt;
      &lt;a class="pr5" title="Dupliquer" href="/backend/web/app_dev.php/fr/of/39/duplicate"&gt;
          &lt;i class="fa fa-files-o" aria-hidden="true"&gt;&lt;/i&gt;
      &lt;/a&gt;
      &lt;a class="pr5" title="Exporter" href="/backend/web/app_dev.php/fr/of/39/export"&gt;
          &lt;i class="fa fa-file-excel-o" aria-hidden="true"&gt;&lt;/i&gt;
      &lt;/a&gt;
      &lt;a class="pr10" title="Modifier" href="/backend/web/app_dev.php/fr/of/39/update"&gt;
          &lt;i class="fa fa-pencil" aria-hidden="true"&gt;&lt;/i&gt;
      &lt;/a&gt;
      &lt;a class="pr5 red" title="Supprimer" href="/backend/web/app_dev.php/fr/of/39/delete"&gt;
          &lt;i class="fa fa-times" aria-hidden="true"&gt;&lt;/i&gt;
      &lt;/a&gt;
  &lt;/td&gt;
  </code></pre>
  
  <p>And looks like this when I see it in console :</p>
  
  <p><a href="https://i.stack.imgur.com/TgYJu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TgYJu.png" alt="enter image description here"></a></p>
  
  <p>The console Is displaying this after the page loading :</p>
  
  <pre><code>/backend/web/app_dev.php/fr/of/elementid/detail
  openModal('/backend/web/app_dev.php/fr/of/elementid/detail');
  </code></pre>
  
  <p><strong>The actual problem :</strong></p>
  
  <p>The second line looks right to me <code>openModal('/backend/web/app_dev.php/fr/of/elementid/detail');</code> , after that, I just need to replace <code>elementid</code> by the actual id contained in <code>data</code> . Thats the part : <code>detail.replace("elementid", data)</code> but this step looks to be wrong.</p>
  
  <p>I don't understand what I'm doing wrong ... Does anybody have an idea ?</p>