1.1.1 • Published 8 years ago

koa-nunjucks-promise v1.1.1

Weekly downloads
11
License
MIT
Repository
github
Last release
8 years ago

koa-nunjucks-promise

NPM version Dependency Status License

nunjucks rendering middleware with promise for koa@next

Installation

$ npm install koa-nunjucks-promise

Example

var Koa = require('koa');
var views = require('koa-nunjucks-promise');

var app = new Koa();

app.use(views('views', {
  ext: 'html',
  noCache: process.env.NODE_ENV === 'development',
  filters: {
    json: function(str) {
      return JSON.stringify(str, null, 2);
    }
  },
  globals: {
    version: 'v8.0.1'
  }
));

app.use(async function(ctx, next) {
  this.state = {
    title: 'app'
  };
  
  await ctx.render('user', {
    user: 'Cat'
  });
});

API

views([root, opts])

  • root (__dirname): __dirname + where your views are located
  • opts: these options go straight to nunjucks.
    • ext: extension of template file

Debug

Set the DEBUG environment variable to koa-nunjucks-promise when starting your server.

$ DEBUG=koa-nunjucks-promise

License

MIT

1.1.1

8 years ago

1.1.0

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago