除非他们是mixin的一部分,否则不允许匿名阻止 - Jade&节点

时间:2014-03-30 16:19:54

标签: javascript node.js pug

我正在Lynda.com上与Joseph LeBlanc一起完成Node.js Essential Training的工作,我似乎和this person有同样的问题,但他们的解决方案对我不起作用。

每当我导航到localhost:3000/list时,我都会收到以下错误:

Anonymous blocks are not allowed unless they are part of a mixin.

/views/layout.jade

doctype html
html
    head
        title= title
        link(rel="stylesheet", href="bootstrap.min.css")
    body
        div.container
            block

/views/list.jade

extends layout

block content
    h1= title
    ul
        each employee, index in allEmployees
            - employee = employee.getInfo()
            li= employee.name

/routes/index.js

exports.list = function(req, res) {
    res.render('list', {
        title: 'All Employees', 
        allEmployees: allEmployees});
};

/app.js

app.get('/list', routes.list);

1 个答案:

答案 0 :(得分:1)

我认为 /views/layout.jade 您需要以下内容。请注意,最后一行仅为block content

block
doctype html
html
    head
        title= title
        link(rel="stylesheet", href="bootstrap.min.css")
    body
        div.container
            block content