See Frits’ answer: You can, but is there really any need? It’s nice and readable the way you’ve done it.
But if you really, really want to, this is how:
exports.about = function(req, res){
res.render('about', {title: 'about page', time: new Date().toLocaleDateString() });
};
It looks a bit odd, but the new Date()
part takes precedence, so you don’t even needs parens around it (e.g., you don’t need time: (new Date()).toLocaleDateString()
). You could have them if you want, but they’re not necessary.
solved How do I reduce this code to one line?