【问题标题】:save HTML for of rendered PUG with dATA用数据保存渲染的 PUG 的 HTML
【发布时间】:2021-06-22 21:03:40
【问题描述】:

我想保存用数据渲染的 pugfile 的 HTML 源代码。

我的路线是:

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

我该怎么做?

【问题讨论】:

    标签: node.js pug


    【解决方案1】:

    有一个来自 .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)
    })
    

    请参阅 herehere

    【讨论】:

      【解决方案2】:

      尝试使用此链接,看看它是否对您有帮助

      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

      那是根据那个帖子

      【讨论】:

      • 欢迎来到 StackOverflow。我们不鼓励“仅链接”的答案。请edit您的帖子包含更多详细信息。
      猜你喜欢
      • 2016-11-13
      • 1970-01-01
      • 2019-04-06
      • 2018-08-16
      • 1970-01-01
      • 2019-04-17
      • 2019-01-19
      • 2022-01-04
      • 2014-10-22
      相关资源
      最近更新 更多