我一直在寻找几个小时,无法找到并回答我为什么会收到此错误。当我尝试渲染视图文件时,我收到错误"字符串不是函数"
服务器
var dust = require("dustjs-linkedin");
var Hapi = require('hapi');
var app = new Hapi.Server({
connections: {
routes: {
files: {
relativeTo: path.join(__dirname, 'public')
}
}
}
});
app.views({
engines: {
dust: dust
},
relativeTo: __dirname,
path: 'views'
});
Index.js
var path = require('path');
var Tv = require('tv');
var app = require(path.join(__dirname, 'server'));
app.connection({ port: process.env.PORT || 80 }); //hapi
app.register(Tv, function (err) {
if (!err) {
app.start(function () {
console.log("Hapi started and listening on port: " + app.info.port);
});
}
});
//we load all the routes here
var routesLoader = require(path.join(__dirname, 'lib/routesLoader'));
routesLoader(app, path.join(__dirname, 'routes'));
路径文件的输入部分
app.route([{
method: 'GET',
path: '/{siteid}/admin',
handler: function (req, res) {
SettingsManager.readSettingsFile().then(function (settings) {
var siteId = req.params.siteid;
res.state("x-site-id", siteId);
var adminData = {siteId: siteId};
for (var i in settings) {
adminData[i] = settings[i].toString();
}
//console.log(adminData);
res.view('admin/admin-menu', adminData);
}, function (err) {
console.log(err);
});
}]);