我在docpad.coffee中定义自定义路由。这是docpadConfig中的事件。
事件:
# Server Extend
# Used to add our own custom routes to the server before the docpad routes are added
serverExtend: (opts) ->
# Extract the server from the options
{server} = opts
docpad = @docpad
# Include our custom routes
#require(__dirname+'/routes.coffee')({docpad,server})
server.get "/home", (req,res,next) ->
document = docpad.getFile("categories/idea.html.eco")
console.log(document)
docpad.serveDocument
document: document
req: req
res: res
next: next
statusCode: 200
return
server.get "/searchHandle", (req,res,next) ->
document = docpad.getFile("searchHandle.html.eco")
console.log(document)
docpad.serveDocument
document: document
req: req
res: res
next: next
statusCode: 200
return
现在是否可以添加我的自定义变量,如somevar:" Hello"我们可以在像
这样的ejs中为文档提供服务res.render('writeNewArticle',{title: "My title"
})