$ npm install koajs-nunjucks
First, require koajs-nunjucks. It returns a function that will return a middleware generator.
var KoajsNunjucks = ;var fMiddleware = ;
The function takes two arguments. They are passed in the same order to the nunjucks.configure() function. Next, "use" the middleware function (before any other middleware that attempts to use it).
var app = ;app;
The render function is attached to the Koa context. It is availiable in other middleware functions directly as "this". The function renders the view and automatically sets it as the response body.
The render function takes two arguments as defined by nunjucks.render. It does NOT take a callback.
In additon to the render function, the enviorment is also attached to the context. Every request creates a fresh enviorment.