queckezz/koa-views

Possible to pass additional engine options?

Closed this issue · 3 comments

For example, ECT has the option for root, that allows you to specify the view route. Without this option set, the extend functionality of ECT doesn't work properly (it needs full layout path). Is there a way to pass this down to ECT somehow? Thanks!

I thought this should work

var app = koa()
var root = __dirname + '/your/path'

app.use(views(root, 'html', {
  html: 'ect'
}));

since the path will go straight to consolidate.js.

Heres the implementation: https://github.com/visionmedia/consolidate.js/blob/master/lib/consolidate.js#L644.

@queckezz thanks for the reply, didn't see it til just now. I gave what you mentioned a shot but no dice, I still need to do something like:
<% extend 'app/views/layout.ect' %> instead of just <% extend 'layout.ect' %> despite having my root directory set up as app/views. Seems like the problem exists both with extend and include functionality. Any other ideas?

Thanks again for your response!

The problem right now is not in koa-views. This module uses consolidate.js which currently doesn't allow engine specific options, see tj/consolidate.js#141. This will probably never get fixed since visionmedia stated that he won't add another options object. So you would be better off to create a seperate module for koa with just ect support or completely switch to another templating language.