title: Accessing EJS variable in Javascript logic
body: <p>I'm working on a Node.js app (it's a game). In this case, I have some code set up such that when a person visits the index and chooses a room, he gets redirected to the proper room. </p>
  
  <p>Right now, it's being done like this with Express v2.5.8:</p>
  
  <pre><code>server.get("/room/:name/:roomId, function (req, res) {
    game = ~databaseLookup~
    res.render("board", { gameState : game.gameState });
  }
  </code></pre>
  
  <p>Over in board.ejs I can access the gameState manner with code like this:</p>
  
  <pre><code>&lt;% if (gameState) { %&gt;
    &lt;h2&gt;I have a game state!&lt;/h2&gt;
  &lt;% } %&gt;
  </code></pre>
  
  <p>Is there a way for me to import this into my JavaScript logic? I want to be able to do something like <code>var gs = ~import ejs gameState~</code> and then be able to do whatever I want with it--access its variables, print it out to console for verification. Eventually, what I want to do with this gameState is to display the board properly, and to do that I'll need to do things like access the positions of the pieces and then display them properly on the screen.</p>
  
  <p>Thanks!</p>