title: How can I get ejs to work with mongoose?
body: <p>I have a route that gets all of the clients and I'm trying to pass the client to ejs to render them. I'm getting the following error:</p>
  
  <pre><code>Express
  500 SyntaxError: Unexpected token {
  at Object.Function (unknown source)
  at exports.compile (/Users/sm/Desktop/AttApp/node_modules/ejs/lib/ejs.js:234:12)
  at Object.exports.render (/Users/sm/Desktop/AttApp/node_modules/ejs/lib/ejs.js:273:10)
  at View.exports.renderFile [as engine] (/Users/sm/Desktop/AttApp/node_modules/ejs/lib/ejs.js:303:22)
  at View.render (/Users/sm/Desktop/AttApp/node_modules/express/lib/view.js:75:8)
  at Function.app.render (/Users/sm/Desktop/AttApp/node_modules/express/lib/application.js:503:10)
  at ServerResponse.res.render [as partial] (/Users/sm/Desktop/AttApp/node_modules/express/lib/response.js:721:7)
  at ServerResponse.module.exports.res.render (/Users/sm/Desktop/AttApp/node_modules/express-partials/index.js:55:9)
  at ServerResponse.res.renderPjax (/Users/sm/Desktop/AttApp/node_modules/express-pjax/pjax.js:17:11)
  at Promise. (/Users/sm/Desktop/AttApp/app.js:61:17)
  </code></pre>
  
  <p>Here is my route:</p>
  
  <pre><code>app.get( '/clients', function( req, res ) {
      return ClientModel.find( function( err, clients ) {
          if( !err ) {
              res.renderPjax('clients/clients.ejs', {
                title: 'Clients Page',
                clients: clients
  
              });
  
              console.log(clients);
          } else {
              return console.log( err );
          }
      });
  });
  </code></pre>
  
  <p>And here is my view client.ejs:</p>
  
  <pre><code>&lt;input type="text" class="table-search" id="search" autocomplete="off" placeholder="Search Clients…"&gt;
  &lt;table class="table" id="tblData"&gt;
          &lt;thead&gt;
          &lt;tr&gt;
          &lt;th&gt;Client Name&lt;/th&gt;
          &lt;th&gt;Title&lt;/th&gt;
          &lt;/tr&gt;
          &lt;/thead&gt;
              &lt;tbody id="tblDataBody"&gt;
              &lt;% clients.forEach(fucntion(client){ %&gt;
  
                  &lt;tr&gt;
                      &lt;td&gt;&lt;a href="http://lar4.loc/clients/&lt;%= client._id %&gt;"&gt;&lt;%= client.first_name %&gt;&lt;/a&gt;&lt;/td&gt;
                      &lt;td&gt;Title&lt;/td&gt;
                  &lt;/tr&gt;
  
              &lt;%  }) %&gt;
  
              &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>How can I get the ejs template to loop through the client data and render it? I'm using mongoose to store and fetch the data. I'm also using express.js.</p>