hmmm again
[ikiwiki.git] / doc / todo / be_more_selective_about_running_hooks.mdwn
1 [[!template  id=gitbranch branch=chrismgray/exclusive-hooks author="[[chrismgray]]"]]
2
3 Sometimes plugins register a function with `hook`, but they only want
4 the function called with the content that they know how to deal with.
5 Normally, this means that they call `pagetype` first thing in the
6 function, determine if they know how to deal with the content, and
7 only do anything if they do.  
8
9 This is a bit wasteful in itself, but for external plugins, it's
10 really bad.  For functions like `scan` and `linkify`, where the entire
11 page is sent back and forth over `stdout` and `stdin`, it really slows
12 things down.  
13
14 Thus, I propose that there be a new optional parameter to `hook` that
15 tells it that the function should only be called for files whose type
16 is the same as the id of the plugin calling `hook`.  I have called
17 this parameter `exclusive` in my branch, but this might not be the
18 best name.
19
20 [[!tag patch]]
21
22 > It's an interesting idea, but it might be more useful if it was more generalized, say, by making it a filter, where the parameter is a regexp.
23
24 > --[[KathrynAndersen]]
25
26 >> Would it make more sense as a pagespec?  That might be a bit more hard to implement, but would certainly fix the naming issue.
27 >>
28 >> --[[chrismgray]]
29
30 >>> Considering where it would be called, a pagespec might be overkill. --[[KathrynAndersen]]