queckezz/koa-views

Could koa-views return a template engine object to config(or operate) it?

Closed this issue · 2 comments

var views = require('koa-views');
app.use(views(__dirname + '/views', {
  map: {
    html: 'swig'
  }
}));

I wana get the template engin object (such as swig), to invoke some method of it, such as swig.setFilter(...),but how could I get the template engine object by the variable views ( var views = require('koa-views'); )?

It looks like koa-views return a generator(a function*) to use, I am not able to get the template engine boject instance to use some method of template engine own.It makes me confused very much...

koa-views is using consolidate under the hood. Taking a quick look at the source, you can only set the cache. Im using consolidate as a hard dependency. What is not supported there, can't be supported here. You can create a pull request so that you can specify filters through options like with handlebars

Maybe something more specific like koa-swig makes more sense here.