0

因此,我尝试了 Vision 文档中的 Nunjucks示例以及插件nunjucks-hapi,结果相同 - 手表不起作用。

var viewPath = Path.join(__dirname, 'views')

var env = NunjucksHapi.configure(viewPath, { watch: true})

server.register(plugins, (err) => {
  if (err) throw err;

  server.views({
    engines: {
      html: NunjucksHapi
    },
    path: viewPath
  });

  server.route(...);

  server.start((err) => {       
  });
});

套餐:

"hapi": "^13.0.0",
"nunjucks": "^2.3.0",
"nunjucks-hapi": "^2.0.1",
"vision": "^4.0.1"

关于在哪里寻找问题的建议?

4

1 回答 1

-1

试试看:

server.register(require('vision'), (err) => { 

    Hoek.assert(!err, err)

    server.views({
        engines: {
           njk: require('nunjucks-hapi')
 	},
        relativeTo: __dirname,
        path: 'resources/views'
    })
})

于 2016-12-03T02:39:25.400 回答