title: Passing an object to client in node/express + ejs?
body: <p>I have a pretty large object that I need to pass to a function in a client script. I have tried using JSON.stringify, but have run into a few issues with this approach - mostly performance related. Is it possible to do something like this in ejs?</p>
  
  <pre><code>app.get('/load', function(req, res) {
      var data = {
          layout:'interview/load',
          locals: {
              interview: '',
              data: someLargeObj
          }
      };
      res.render('load', data);
  });
  </code></pre>
  
  <p>And in my client script, I would pass this object to a function like so</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      load(&lt;%- data %&gt;); // load is a function in a client script
  &lt;/script&gt;
  </code></pre>
  
  <p>When I try this I get either</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      load();
  &lt;/script&gt;
  </code></pre>
  
  <p>or</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      load([Object object]);
  &lt;/script&gt;
  </code></pre>