NodeJS: Render download file to EJS template
Here's a simple way to use NodeJS and Express to render an EJS template that forces a file download. Any JSON objects (ie; foo, bar) are passed through to your EJS template, so that the downloaded file can contain dynamic data from the server...
app.get('/download', function(req, res){
res.attachment('filename.html');
res.render('download',{foo:foo, bar: bar));
})
Written by Carol Skelly
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Node
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#