Html Swig模板和Node.js

Html Swig模板和Node.js,html,node.js,http,swig-template,Html,Node.js,Http,Swig Template,我对swig模板和node.js有问题 我的代码: nodejs_swig.js文件的路径:/node nodejs\u swig.js://\u目录名为/node var http = require('http'), swig = require(__dirname + '/node_modules/swig'); swig.init({ root: '/web/public/', allowErrors: true }); console.log(swig); h

我对swig模板和node.js有问题

我的代码:

nodejs_swig.js文件的路径:/node

nodejs\u swig.js://\u目录名为/node

var http = require('http'),
    swig = require(__dirname + '/node_modules/swig');

swig.init({
    root: '/web/public/',
    allowErrors: true
});
console.log(swig);
http.createServer(function (req, res) {
    var tmpl = swig.compileFile('page.html'),
        renderedHtml = tmpl.render({
            people: [
            { name: 'Paul', age: 28 },
            { name: 'Jane', age: 26 },
            { name: 'Jimmy', age: 45 }
            ],
            title: 'Basic Example'
        });

    res.writeHead(200, { 'Content-Type': 'text/html' });
    res.end(renderedHtml);
}).listen(1337);

console.log('Application Started on http://localhost:1337/');
html文件在此处:/web/public

page.html文件:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>{{ title }}</title>  
    </head>
    <body>    
        <h1>{{ title }}</h1>    
        <ul>
            {% for person in people %}
                <li>{{ person.name }} age {{ person.age }}</li>
            {% endfor %}
        </ul>    
    </body>
</html>
这是我在屏幕上看到的输出

有人知道怎么回事吗

提前感谢,

对不起,我的英语不好

{{ pagename|title }}

{% for author in authors %} {{ author }} {% else %}
There are no authors.
{% endfor %}