From: spalax Date: Mon, 13 Jan 2014 20:23:43 +0000 (-0400) Subject: Solution? X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/commitdiff_plain/df405eb1253e4f9c45465efc1751a0cbe2845b5e Solution? --- diff --git a/doc/forum/inject__95__preprocess__95__tag.mdwn b/doc/forum/inject__95__preprocess__95__tag.mdwn index bf2bc4f90..2b41b5b76 100644 --- a/doc/forum/inject__95__preprocess__95__tag.mdwn +++ b/doc/forum/inject__95__preprocess__95__tag.mdwn @@ -48,3 +48,28 @@ Here is the full code of (a very early version of) my plugin. 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]] +