title: How to render multiple .ejs files in nested form in Node.js and Express?
body: <p>How can I render multiple <code>.ejs</code> files in a nested form?</p>
  
  <p>So I have the following file:</p>
  
  <pre><code>var mysql = require('mysql');
  var ejs = require('ejs');
  exports.index = function(req, res){
      if (req.method=='POST'){
          var connection = mysql.createConnection({user:'root', password:'root', database:'testdb'});
          var name = req.param('name');
          connection.query('select * from table_name where name = ?', name, function(err, rows, fields){
              if(err) throw err;
              res.render('index', {
                   title: 'title', content: res.render('index2', {data:rows})
              });
          });
      }
  });
  </code></pre>
  
  <p>Where <code>index.ejs</code> consists of very basic html tag (say html, head, body, and one <code>p</code> tag) and have <code>&lt;%- content %&gt;</code> in it, where content is assumed to be rendered by another .ejs file, which doesn't include html, head, or body tag and is only assumed to be rendered a content and a title. However, when I accessed to this file by POST request and tried to render files and then checked out the outputted HTML file from my browser, the content consisted only of <code>index2.ejs</code> file, which means it has no html, body, head tag.</p>
  
  <p>So what am I missing? And if I want to include a Javascript library by <code>&lt;script src='some_file.js'&gt;&lt;/script&gt;</code>, should I add another rendering property when I try to render in <code>index2.ejs</code> file...right?</p>