]> sipb.mit.edu Git - ikiwiki.git/commitdiff
Solution?
authorspalax <spalax@web>
Mon, 13 Jan 2014 20:23:43 +0000 (16:23 -0400)
committeradmin <admin@branchable.com>
Mon, 13 Jan 2014 20:23:43 +0000 (16:23 -0400)
doc/forum/inject__95__preprocess__95__tag.mdwn

index bf2bc4f901c25db5718cf006ef4fd30e31815640..2b41b5b762dbd5e39d6533bed02a64f4a92ae014 100644 (file)
@@ -48,3 +48,28 @@ Here is the full code of (a very early version of) my plugin.
     1
 
 -- [[Louis|spalax]]
     1
 
 -- [[Louis|spalax]]
+
+> Hello,    
+> I managed to replace the tag original `preprocess_tag` function, using a different approach than using `inject`:
+> 
+>     my $orig_preprocess_tag;
+> 
+>     sub import {
+>       IkiWiki::loadplugin("tag");
+>       $orig_preprocess_tag = \&{$IkiWiki::hooks{preprocess}{tag}{call}};
+>       hook(type => "preprocess", id => "tag", call => \&my_preprocess_tag);
+>     }
+> 
+> And later on, I can call the original `preprocess_tag` function using:
+> 
+>     $orig_preprocess_tag->(...)
+> 
+> The problem is that I am digging into `IkiWiki.pm` package to extract data from `IkiWiki::hooks`, which is not guaranteed to work in the future, contrary to `inject`.
+> 
+> Two questions:
+> 
+> - how ugly is my solution?
+> - is it possible to use `inject` to replace the `IkiWiki::Plugin::tag::preprocess_tag` function?
+> 
+> -- [[Louis|spalax]]
+