title: How to replace break lines in twig
body: <p>I want to fill a JavaScript array with values from PHP variables using TWIG.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
     var cont=new Array();
     {% for key, post in posts %}
     cont[{{ key }}] = "{{ post.content }}";
     {% endfor %}
  &lt;/script&gt;
  </code></pre>
  
  <p>The problem is that I have <code>post</code> variable with several lines, so the above code make JS commands separated to few lines, that is translated as several commands, and I have an error.</p>
  
  <p>So I think that I need to replace all the 'new lines' to "\n".</p>
  
  <p>I tried to do like this:</p>
  
  <pre><code>cont[{{ key }}] = "{{ post.content | replace({"\n":"&lt;br&gt;"}) }}";
  </code></pre>
  
  <p>But it does not help. It still stay as few lines…</p>