我在 NodeJS 中有一个问题,我是新手。我正在使用 nodeJS、express 和 JQTPL 来遵循有关调用 github API 的教程,但问题出在应用程序配置上,特别是在引擎定义上。
var express = require('express'),
app = express(),
...
;
app.configure(function(){
app.set('view engine', 'html');
app.set('view options', {layout: false});
app.engine('.html', require('jqtpl').__express);
});
// When we go to the URL "/" we go the the index.html
app.get("/", function(req, res){
res.render("index");
});
app.get("/board", function(req, res) {
res.render("board");
})
app.engine 调用失败,这是错误:
if ('function' != typeof fn) throw new Error('callback function required');
^
Error: callback function required
at Function.app.engine (/var/lib/stickshift/51d5872b5973ca8338000033/app-root/data/547742/node_modules/express/lib/application.js:173:38)
at Function. (/var/lib/stickshift/51d5872b5973ca8338000033/app-root/data/547742/app.js:15:9)
at Function.app.configure (/var/lib/stickshift/51d5872b5973ca8338000033/app-root/data/547742/node_modules/express/lib/application.js:392:61)
at Object. (/var/lib/stickshift/51d5872b5973ca8338000033/app-root/data/547742/app.js:12:5)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)
at process.startup.processNextTick.process._tickCallback (node.js:244:9)
我明白什么是回调……等等……但是我发现调用 app.engine 的唯一方法是这样构建的。
谢谢您的帮助 !