简体   繁体   English

在PUG中运行简单的Hello World问题

[英]Issue running simple hello world in PUG

Guys I have problems running a simple example with PUG. 伙计们,我在使用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. userdetails.pug文件与包含上述功能的index.js文件位于同一目录中。

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. 但是,当我用get命中该地址时,浏览器挂起。 Can someone help? 有人可以帮忙吗?

愚蠢的我,我固定了它必须使用send将渲染结果发送回浏览器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM