Is there a way to render template to a variable instead to output?
res.render('list.ejs', { posts: posts });
something like this
var list = render('list.ejs', { posts: posts });
The easiest way to do that is to pass a callback to res.render, in your example:
res.render
res.render('list.ejs', {posts: posts}, function(err, list){ // });
But if you want to render partial templates in order to include them in another template you definitely should have a look at view partials.
2.1m questions
2.1m answers
60 comments
57.0k users