Fix For Docpad TagCloud Plugin After Update To 6.65.0

Tuesday, 20 May 2014
  • By
  • Jeff Ammons
  • Tags:
  • Programming
  • DocPad

Quick update for anyone running DocPad and the TagCloud plugin.

When I updated DocPad tonight, the TagCloud plugin stopped working.

Long story short, I'm guessing something has changed that now requires an explicit reference to the docpad object that was implicit before.

I'm a noob at DocPad and beyond a nood at CoffeeScript, but it wasn't too difficult to track down the problem and fix it.

I've issued a pull request on the TagCloud project, but I can give you a hack fix here to hold you until the plugin is updated.

Temporary Hack Fix

In your project's directory navigate to /node-modules/docpad-plugin-tagcloud/out and edit tagcloud.plugin.js.

Find the following code:

TagCloud.prototype.renderBefore = function(_arg, next) {
  var collection, config, item, tag, tagDocs, templateData, _ref1,
    docpad, _this = this;
  collection = _arg.collection, templateData = _arg.templateData;
  config = this.getConfig();

  this.tagCloud = {};
  this.maxCount = 0;

Now add docpad = this.docpad; right after config = this.getConfig();

That will give you this:

TagCloud.prototype.renderBefore = function(_arg, next) {
  var collection, config, item, tag, tagDocs, templateData, _ref1,
    docpad, _this = this;
  collection = _arg.collection, templateData = _arg.templateData;
  config = this.getConfig();
  docpad = this.docpad;
  this.tagCloud = {};
  this.maxCount = 0;

Once you make that change, you should be back in business.

Actual Fix

Of course the actual fix will have to come from the plugin's author, but as I said, I've issued a pull request.

The CoffeeScript code is of course similar, but all CoffeeScriptee.

docpad = @docpad

Hope this helps.