Closed ericman314 closed 6 years ago
This worked:
app.get('/page3', function(req, res) {
res.context = {
message: "Hello from page3",
layout: "alternate"
};
res.render('../views/index.handlebars', res.context);
});
Edit: The reason I'm using res.context
is that in my application I have some middleware attached which adds some common data to each page via res.context
. I guess that you could use an ordinary object as the second argument to render
.
I cannot figure out how to call
render()
with both a non-default layout and a context. I can do one or the other:server.js:
views/index.handlebars:
views/layouts/main.handlebars:
views/layouts/alternate.handlebars:
Results
The last request fails with
TypeError: callback is not a function
atlib/utils.js:26
.What am I doing wrong?