2017-06-15 130 views
0

所以我有一个node.js应用程序使用表示ejs来呈现模板。我知道通过在我的应用程序对象中使用res.render(),我可以发送呈现的响应。但是,有没有什么办法只是使用渲染引擎得到output'ed html?node.js - 使用模板引擎返回html

回答

0

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