我正在尝试将一个Express应用与Docpad集成。我最想要的是在我的静态页面和我的Express视图之间共享布局。
在此过程中,我按照问题16332833的说明进行操作,并使用:
var docpadInstanceConfiguration = {
action: 'generate',
env: 'static'
};
require('docpad').createInstance(docpadInstanceConfiguration, function(err,docpadInstance){
if (err) return console.log(err.stack);
// ...
});
我收到以下错误:
info: Generating...
notice: DocPad is currently running without any plugins installed. You probably want to install some: http://docpad.org/plugins
TypeError: path must be a string
at fs.exists (fs.js:166:11)
at Task.method (/Users/../node_modules/docpad/node_modules/safefs/out/lib/safefs.js:183:14)
at ambi (/Users/../node_modules/docpad/node_modules/ambi/out/lib/ambi.js:22:16)
at /Users/../node_modules/docpad/node_modules/taskgroup/out/lib/taskgroup.js:117:19
at b (domain.js:183:18)
at Domain.run (domain.js:123:23)
at Task.fire (/Users/../node_modules/docpad/node_modules/taskgroup/out/lib/taskgroup.js:116:21)
at process._tickCallback (node.js:415:13)
at Function.Module.runMain (module.js:499:11)
at startup (node.js:119:16)
at node.js:901:3
没有选项,var docpadInstanceConfiguration = {};
没有错误:
info: Welcome to DocPad v6.52.1
info: Contribute: http://docpad.org/docs/contribute
info: Plugins: cleanurls, coffeescript, downloader, eco, less, livereload, marked, partials, related, stylus, text
info: Environment: development
是否有想法在docpad和express视图之间获取共享布局,并获得csrf保护? (我正在使用ectjs查看我的观点,是生态兼容的)
由于
答案 0 :(得分:0)
原来你需要在load
之前执行ready
和generate
操作,如下所示:
var docpadInstanceConfiguration = {
action: 'load ready generate',
env: 'static'
};
require('docpad').createInstance(docpadInstanceConfiguration, function(err,docpadInstance){
if (err) return console.log(err.stack);
// ...
});
然而,看看API docs它似乎没有以这种方式采取行动是正确的方式,而是我们应该这样做:
var docpadInstanceConfiguration = {
env: 'static'
};
require('docpad').createInstance(docpadInstanceConfiguration, function(err,docpadInstance){
if (err) return console.log(err.stack);
var generateOpts = {};
docpadInstance.action('generate', generateOpts, function(err,result){
if (err) return console.log(err.stack);
// ...
});
});