Question: I want to save HTML source of my pugfile rendered with data.

My route is:

```
res.render('pugfile', { data: resp });

```

How can I do that?

Answer: 
There's a callback from .render().

```js
res.render('pugfile', { data: resp }, function (err, pageBody) {
    if (err) throw err
    /* manipulate pageBody as you will,
     * but be sure to .send it to the browser if
     * you use this callback. */
    res.send(pageBody)
})

```

See [here](https://stackoverflow.com/questions/13362381/how-to-compile-jade-template-file-to-get-string) and [here](http://expressjs.com/en/api.html#res.render).
Try using this link and see whether it will be helpfull to you  

[link to possible answer](https://stackoverflow.com/a/61239305/15770919 "https://stackoverflow.com/a/61239305/15770919")  

`The createTemplateFile function simply creates a new file if it doesn't exist.`

`The exportTemplateFile function saves the HTML in the html variable rendered by pug and prettifies it with the pretty package and then overwrites the new template file`

Thats according to that post