mde / ejs

Embedded JavaScript templates -- http://ejs.co
Apache License 2.0
7.76k stars 842 forks source link

Get rendered file at runtime #581

Closed ghost closed 3 years ago

ghost commented 3 years ago

Hello,

I am working on a website where I want to separate dynamic server side content from static client side responses. for curious ones, I want to expose a front end version to contributors (on style mainly) to work on freely. but at the same time, I want to keep my server side repository private for few collaborators.

I can simply run a request and then manually copy rendered content to the other public repository. However as the web app evolves, I want to make a function in Nodejs that could hopefully export a render for some requests into HTML along with dependencies (JS/ CSS/ PNGs).

To put it simple, this code here is a response to a request,

app.get('/', function (req, res) {
  res.render('index')
})

And other requests. All I want is to catch res.render and export it to a file somehow.

ghost commented 3 years ago

Sorry, my bad, there is ejs.render just for this.