queckezz / koa-views

Template rendering middleware for koa (hbs, swig, pug, anything! :sparkles:)
MIT License
710 stars 87 forks source link

How to use .njk suffix for file name using nunjacks engine? #84

Closed silent-tan closed 7 years ago

silent-tan commented 7 years ago
// views
app.use(views(path.join(__dirname, '../views'), {
  extension: 'nunjucks'
}));

my view file is xxx.njk

but make error: ... can not found xxx.nunjucks

queckezz commented 7 years ago
app.use(views(path.join(__dirname, '../views'), {
  map: { njk: 'nunjucks' },
  extension: 'njk'
}));

whereas extension is optional. This is so you can just do this.render('./view') instead of this.render('./view.njk')

Let me know if this helps :1st_place_medal:

silent-tan commented 7 years ago

thanks