【问题标题】:node.js - use template engine to return htmlnode.js - 使用模板引擎返回 html
【发布时间】:2017-06-15 13:40:01
【问题描述】:

所以我有一个 node.js 应用程序,它使用 expressejs 来呈现模板。我知道通过在我的应用程序对象中使用res.render(),我可以发送呈现的响应。但是有没有办法只使用渲染引擎来获得输出的html?

【问题讨论】:

    标签: node.js template-engine


    【解决方案1】:

    只需查看the expressjs documentation for the Response object。 Response.render 是这样定义的:res.render(view [, locals] [, callback])。通过以function(err, html) 的形式提供回调函数,渲染引擎将使用 html 字符串调用您的回调函数,而不是直接将其发送到服务器。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-07-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-12
      • 2010-12-19
      • 1970-01-01
      相关资源
      最近更新 更多