]> sipb.mit.edu Git - ikiwiki.git/blob - doc/forum/inject__95__preprocess__95__tag.mdwn
style
[ikiwiki.git] / doc / forum / inject__95__preprocess__95__tag.mdwn
1 [[!meta title="Cannot manage to inject preprocess_tag"]]
2
3 Hello,    
4 I am trying to write a plugin that changes the way the
5 [[ikiwiki/directive/tag]] [[ikiwiki/directive]] works, and I am trying to do so
6 by using the [[inject|plugins/write/#index81h3]] function. The piece of code
7 that should (if I understood well the `inject` function) do the trick is :
8
9       sub import {
10         inject(
11           name => 'IkiWiki::Plugin::tag::preprocess_tag',
12           call => \&my_preprocess_tag
13         );
14       }
15
16 Howere, this does not change anything about the effect of the `tag` directive.
17
18 I have tried some variants, like calling `inject` outside the `import`
19 function, or calling `IkiWiki::loadplugin("tag");` to ensure that the
20 [[plugins/tag]] is loaded, but none of these things work. Any idea?
21
22 *Disclaimer:* although proficient in several languages, I am a beginner in Perl.
23
24 Here is the full code of (a very early version of) my plugin.
25
26     #! /usr/bin/perl
27     require 5.002;
28     package IkiWiki::Plugin::parenttag;
29
30     use warnings;
31     use strict;
32     use IkiWiki 3.00;
33
34     my $orig_preprocess_tag=\&preprocess_tag;
35
36     sub import {
37       inject(
38         name => 'IkiWiki::Plugin::tag::preprocess_tag',
39         call => \&my_preprocess_tag
40       );
41     }
42
43     sub my_preprocess_tag(@) {
44       print "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nWorking!\n";
45       return "TODO";
46     }
47
48     1
49
50 -- [[Louis|spalax]]