Guys I have problems running a simple example with PUG. I installed it (have it in dependencies). Here is code how I use it
app.get('/users/:id',function (req, res) {
var user = userDatabase.find(req.params.id);
// user is well defined here
pug.renderFile('userdetails.pug', {
id:user.id,
name: user.name,
lastname:user.surname
});
});
Here is require
const pug = require('pug');
The userdetails.pug file is located in the same directory as the index.js file which contains above function.
Here is pug file:
h1 User Details
p ID: #{id}
p name: #{name}
p surname: #{lastname}
But when I hit that address with get, browser hangs. Can someone help?
愚蠢的我,我固定了它必须使用send将渲染结果发送回浏览器。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.