我从这里做了所有步骤:
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
。
我错过了什么?