0

tldr; Is there a way to expose functions defined in one plugin for another plugin to use?

I'm trying to use the tagging plugin (https://github.com/rantecki/docpad-plugin-tagging) within a partial.

I have a Jade partial setup as follows:

.post-tags
  | Posted in 
  each tag in tags
    a(href=getTagUrl(tag))= tag + ' '

where getTagUrl is a function defined by the tagging plugin. The problem is that the partial has no knowledge and this partial does not render.

2 Answers2

2

As v2.8.0+ of the partials plugin now includes the template data by default (you don't have to manually specify it's inclusion anymore), try running docpad update in your project's root directory and trying again. Otherwise, we'll probably have to see the source code of your project to help isolate the issue.

balupton
  • 47,113
  • 32
  • 131
  • 182
0

It's because partial do not have access by default to templateData, the object holding the getTagUrl helper. You have to pass it explicitly to the partial.

Here's a similar answer provided for the eco templating language :

https://stackoverflow.com/a/16631649/232943

Community
  • 1
  • 1
Delapouite
  • 9,469
  • 5
  • 36
  • 41
  • 1
    For what it's worth, the partials plugin v2.8.0+ now includes template data by default. I've updated the answer you've linked to reflect this. Thanks! :) – balupton Aug 23 '13 at 23:35