title: node.js + express + handlebars render multiple views in a single request
body: <p>I'm trying to understand if I can render via the res.render() function or in some other way a multiple set of view(s).</p>
  
  <p>In the home.handlebars I have the following code</p>
  
  <pre><code>&lt;h1&gt;Home&lt;/h1&gt;
  </code></pre>
  
  <p>and I want to replicate it into the default layout a "N" number of times.</p>
  
  <p>After looking around as far as I understand the .render() function commits the entire transmission so if i write multiple res.render(); res.render(); is not going to work.</p>
  
  <p>Am I approaching this from a complete wrong side or I am missing something? 
  Do I need to create a "dynamic" view and than pass it one single time to the res.render()?</p>
  
  <p>Thanks.</p>
  
  <p>Attached code for test purposes:</p>
  
  <pre><code>var express=require('express');
  var app=express();
  
  // set up handlebars view engine
  var handlebars = require('express-handlebars').create({ defaultLayout:'main' });
  
  app.engine('handlebars', handlebars.engine);
  app.set('view engine', 'handlebars');
  
  
  app.set('port', process.env.PORT || 8888);
  
  app.use(express.static(__dirname+'/public'));
  
  app.get('/', function(req, res) {
      res.render('home');
      res.render('home');
      res.render('home');
  });
  
  
  // 404 catch-all handler (middleware)
  app.use(function(req, res, next){
      res.status(404);
      res.render('404');
  });
  
  // 500 error handler (middleware)
  app.use(function(err, req, res, next){
      console.error(err.stack);
      res.status(500);
      res.render('500');
  });
  
  app.disable('x-powered-by');
  
  app.listen(app.get('port'),function(){
      console.log('express started on port:'+app.get('port'));
  });
  </code></pre>