X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/39ebfd9491f314b08862ae6bbf538f74caea2039..28c3e5482d7431b7554e6288bb2f9f55fbd274ed:/doc/forum/inject__95__preprocess__95__tag.mdwn?ds=sidebyside diff --git a/doc/forum/inject__95__preprocess__95__tag.mdwn b/doc/forum/inject__95__preprocess__95__tag.mdwn index fe824d840..2b41b5b76 100644 --- a/doc/forum/inject__95__preprocess__95__tag.mdwn +++ b/doc/forum/inject__95__preprocess__95__tag.mdwn @@ -1,4 +1,4 @@ -[[!meta title="Cannot manage to *inject* *preprocess_tag*"]] +[[!meta title="Cannot manage to inject preprocess_tag"]] Hello, I am trying to write a plugin that changes the way the @@ -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]] +