0

I'm intending to use some ejs templates to generate HTML for sending out emails.

I'd like to pass in a model to my view, and get back the resulting HTML So, instead of render() - i want to 'get' the html into a variable before it's passed back to the browser?

Is that possible?

Alex
  • 37,502
  • 51
  • 204
  • 332

1 Answers1

1

Something like the following will work:

var ejs = require('ejs');
var str = ejs.render("<title><%= title %></title>", {title: 'Hello'});
console.log(str);
deltanovember
  • 42,611
  • 64
  • 162
  • 244