0

我正在尝试将一个 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 作为我的观点,是生态兼容的)

谢谢

4

1 回答 1

0

原来你需要loadready之前的动作generate,像这样:

var docpadInstanceConfiguration = {
    action: 'load ready generate',
    env: 'static'
};
require('docpad').createInstance(docpadInstanceConfiguration, function(err,docpadInstance){
    if (err)  return console.log(err.stack);
    // ...
});

然而,查看API 文档,以这种方式执行操作似乎根本不是正确的方式,而是我们应该这样做:

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);
        // ...
    });
});
于 2013-09-10T07:47:56.860 回答