title: Unexpected token return in ,while compiling ejs
body: <p>I am trying to develop a guestbook app which stores users names, country and users message sin mongodb, the connection is ok, I can submit these 3 infos(username, country and message)in the db.  My Issue is to RENDER the messages into my "guestbook.ejs" page.</p>
  
  <p>I would appreciate If anyone can give me a clue on the issue I encounter.</p>
  
  <pre><code>SyntaxError: Unexpected token return in /Users/mesfint/Desktop/MEAN_DEV'T/Guestbook-application/views/pages/guestbook.ejs while compiling ejs
  
  If the above error is not helpful, you may want to try EJS-Lint:
  https://github.com/RyanZim/EJS-Lint
     at Object.Function (&lt;anonymous&gt;)
     at Object.Template.compile (/Users/mesfint/Desktop/MEAN_DEV'T/Guestbook-application/node_modules/ejs/lib/ejs.js:524:12)
     at Object.compile (/Users/mesfint/Desktop/MEAN_DEV'T/Guestbook-application/node_modules/ejs/lib/ejs.js:338:16)
     at handleCache (/Users/mesfint/Desktop/MEAN_DEV'T/Guestbook-application/node_modules/ejs/lib/ejs.js:181:18)
     at tryHandleCache (/Users/mesfint/Desktop/MEAN_DEV'T/Guestbook-application/node_modules/ejs/lib/ejs.js:203:14)
     at View.exports.renderFile [as engine] (/Users/mesfint/Desktop/MEAN_DEV'T/Guestbook-application/node_modules/ejs/lib/ejs.js:412:10)
     at View.render (/Users/mesfint/Desktop/MEAN_DEV'T/Guestbook-application/node_modules/express/lib/view.js:126:8)
     at tryRender (/Users/mesfint/Desktop/MEAN_DEV'T/Guestbook-application/node_modules/express/lib/application.js:639:10)
     at EventEmitter.render (/Users/mesfint/Desktop/MEAN_DEV'T/Guestbook-application/node_modules/express/lib/application.js:591:3)
     at ServerResponse.render (/Users/mesfint/Desktop/MEAN_DEV'T/Guestbook-application/node_modules/express/lib/response.js:960:7)
  </code></pre>
  
  <p>guestbook.ejs</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
  
      &lt;% include ../partials/head %&gt;
  &lt;/head&gt;
  
  &lt;body class="container"&gt;
  
      &lt;header&gt;
          &lt;% include ../partials/header %&gt;
  
  
      &lt;/header&gt;
      &lt;main&gt;
          &lt;div class="jumbotron"&gt;
              &lt;h4&gt;&lt;%= guest_message %&gt;&lt;/h4&gt;
             &lt;table  border = "1"&gt;
                 &lt;tr&gt;
  
                      &lt;th&gt;Name&lt;/th&gt;
                      &lt;th&gt;Country&lt;/th&gt;
                      &lt;th&gt;Message&lt;/th&gt;
                  &lt;/tr&gt;
             &lt;!-- &lt;% jsonData.forEach(function(users){%&gt;--&gt;
              &lt;% for(var i=0; i&lt;newmessage.length; i++) {%&gt;
  
  
                  &lt;tr&gt;
  
                      &lt;td class="userInput"&gt;&lt;%= newmessage[i].username %&gt;&lt;/td&gt;
                      &lt;td class="userInput"&gt;&lt;%= newmessage[i].country %&gt;&lt;/td&gt;
                      &lt;td class="userInput"&gt;&lt;%= newmessage[i].message %&gt;&lt;/td&gt;
                  &lt;/tr&gt;
  
  
              &lt;%} %&gt;
              &lt;/table&gt;
  
  &lt;/div&gt;
      &lt;/main&gt;
  
       &lt;footer&gt;
  &lt;% include ../partials/footer %&gt;
  &lt;/footer&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>server.js</p>
  
  <pre><code>    var express = require("express");
      var bodyParser = require('body-parser');
      var app = express();
      var fs = require("fs");
      var MongoClient = require('mongodb').MongoClient;
  
      var db;
  
  
  app.set('view engine', 'ejs');
  app.use(bodyParser.urlencoded({extended: true}));
  app.use(bodyParser.json());
  app.use(express.static('public'));
  
      MongoClient.connect('mongodb://mesfin:######@ds137090.mlab.com:37090/guestbook', function(err, database)  {
    if (err) return console.log(err)
    db = database;
    app.listen(3000, function () {
      console.log('listening on 3000');
    })
  })
  
      app.get("/", function(req,res){
      res.render("pages/index", {
  
          title_index: "What we speak?",
           content_index:"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore",
  
           footer_index:"My footer goes here"
          });
  
  
      });
  
  
      app.get("/guestbook", function(req,res){
  
         // res.render("pages/guestbook",{
        db.collection('newmessage').find().toArray(function (err, result)  {
      if (err) return console.log(err)
      res.render('pages/guestbook', {newmessage: result});
  
    });
  
          });
  
  
      app.get("/newmessage", function(req,res){
          res.sendFile(__dirname  + "/pages/newmessage");
  
          res.render("pages/newmessage",{
              add_newMessage:"Add Your info &amp; message!"
          });
  
      });
  
      app.post("/newmessage" , function(req,res){
  db.collection('newmessage').save(req.body, function(err, result) {
      if (err) return console.log(err);
      console.log('saved to database');
      res.redirect('/');
    });
  
      });
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/pMIHp.png" rel="noreferrer"><img src="https://i.stack.imgur.com/pMIHp.png" alt="sample insertd data from Mongodb"></a></p>