title: Escaping single quotes in stringified JSON thats passed as EJS template to view
body: <p>I have a NodeJS app that uses EJS templating for injecting variables from the server into the view. I'm having trouble with a particular value, which is an array containing objects whose values may contain an apostrophe. I have to wrap the EJS template string in a single quote when passing to JSON.parse, and as a result the apostrophe gets confused as the end of the string being passed to JSON.parse. I've tried escaping the apostrophe with no luck.</p>
  
  <pre><code>&lt;script&gt;
    window.foo = JSON.parse('&lt;%- JSON.stringify([{"bar": "baz's lorem ipsum"}]) %&gt;');
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>Interprets to:</strong></p>
  
  <pre><code>&lt;script&gt;
    // the string is cut off between the first quote &amp; baz's apostrophe
    window.foo = JSON.parse('[{"bar": "baz's lorem ipsum"}]');
  &lt;/script&gt;
  </code></pre>