Pass variable when serveDocument in Docpad

44 views Asked by At

I am defining custom routes in my docpad.coffee. Here is the events inside docpadConfig.

events:

# 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    

Now Is it possible to add my custom variables like somevar: "Hello" while serve the document as we can do in ejs like

res.render('writeNewArticle',{title: "My title"

})
0

There are 0 answers