【发布时间】:2013-08-06 15:53:17
【问题描述】:
我从 here 开始执行所有步骤:
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。
我错过了什么?
【问题讨论】:
-
我发现了一个问题。每个 DocPad 插件必须在
package.json中有"keywords": {"docpad-plugin"}属性,否则 docpad 会忽略它。
标签: node.js templates plugins content-management-system docpad