I'm working my way through Node.js Essential Training with Joseph LeBlanc on Lynda.com and I seem to have the same problem as this person, but their solution didn't work for me.

Whenever I navigate to localhost:3000/list I get the following error:

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);
有帮助吗?

解决方案

I think for /views/layout.jade you want the following. Note that last line as block content over just block

doctype html
html
    head
        title= title
        link(rel="stylesheet", href="bootstrap.min.css")
    body
        div.container
            block content
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top