0

我从这里做了所有步骤:

1)使用以下代码创建了简单的插件/plugins/myplugin/myplugin.plugin.coffee:

module.exports = (BasePlugin) ->
  class MyPlugin extends BasePlugin
    name: 'myplugin'
    renderBefore: ({templateData}) ->
      templateData.foo = 'bar'

2) /plugins/myplugin/package.json

{
  "name": "myplugin",
  "version": "2.0.0",
  "main": "./src/myplugin.plugin.coffee"
}

3) /src/documents/index.html.eco

<p><%= @foo %></p>

但是插件不起作用。它不在 DocPad 的日志中info: Plugins: eco并抛出错误ReferenceError: foo is not defined

我错过了什么?

4

1 回答 1

2

你有/plugins/myplugin/myplugin.plugin.coffee然后引用它"main": "./src/myplugin.plugin.coffee"- 它期望插件文件位于src这样的目录中:/plugins/myplugin/src/myplugin.plugin.coffee- 你需要更正其中一个。

如果您可以将我链接到文档混淆的地方,我会很乐意修复它。

DocPad 还要求插件在其package.json文件中包含以下内容:

"keywords": ["docpad-plugin"]

于 2013-08-07T03:52:32.210 回答