来源:github
在尝试通过 expressjs 的render函数传递一个新实例化的 mongoose.model 时,我遇到了以下错误:“ReferenceError:jade is not defined”
控制器...
var mongoose = require("mongoose")
  , Client = mongoose.model("Client")
exports.new = function (req, res) {
    res.render("clients/new", {
        headline: "New Client",
        client: new Client({})
    })
}
我也尝试过client: new Client(),将实例化的对象存储在 var 中,然后将其传递给最终的渲染对象而不做任何更改。删除该new Client({})位可以解决 500 错误,但不能解决手头的问题。
一些配置...
app.set("views", __dirname + "/app/views")
app.set("view engine", "jade")
该模型...
var mongoose = require("mongoose")
  , Schema = mongoose.Schema
var Client = new Schema({
    company: { type: String },
    contact: {
        name: { type: String },
        phone: { type: String },
        email: { type: String }
    },
    created: { type: Date, default: Date.now }
})
mongoose.model("Client", Client)
节点 v0.8.12 
Express >= v3.0.0 
Mongoose v3.3.1 
Jade v0.27.6  
来源:github