0

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?

Mariano
  • 473
  • 3
  • 12

2 Answers2

2

There's a callback from .render().

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 and here.

O. Jones
  • 103,626
  • 17
  • 118
  • 172
0

Try using this link and see whether it will be helpfull to you

link to possible answer

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

OBrien Evance
  • 704
  • 5
  • 18
  • Welcome to StackOverflow. We discourage "link-only" answers. Please [edit] your post to include more details. – O. Jones Jun 22 '21 at 13:00