Open mypark opened 8 years ago
+1
PR welcome!
+1
+1
https://github.com/tj/consolidate.js/blob/master/lib/consolidate.js#L1044 https://mozilla.github.io/nunjucks/api.html#renderstring
Same as render, but renders a raw string instead of loading a template.
Should not use renderString
@rambo-panda submit a PR?
@rambo-panda is right. I think both consolidate.js & co-views should be fixed. passing co-views "dir" param to consolidate?
In the mean time I can make it work like this. It looks dumb but it is the only solution we have.
const render = views(__dirname + '/../views', {
default: 'njk',
map: {
njk: 'nunjucks'
},
locals: {
settings: {
views: [__dirname + '/../views']
}
}
});
+1 with koa-views 4.x
@rambo-panda is right.
solve my promblem
@rambo-panda @kyuwoo-choi thanks
If you extend a base layout using nunjucks with co-views, it seems to lose the relative path and requires you to set the full path
For instance, this template will only work if you use the full absolute path to layout.html, otherwise it will error
Error: template not found: layout.html
render.js
index.html