From: www-data Date: Wed, 3 May 2006 20:31:16 +0000 (+0000) Subject: web commit by joey X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/commitdiff_plain/1478bab0cdf13b0a1ed09e5247bada907d245a47?hp=82594b5f8907f529e3e8056282ff72acece7333f web commit by joey --- diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index f9395eb5e..165627f99 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -22,15 +22,33 @@ ikiwiki's processing. The function uses named parameters, and use varies dependi ## Writing a [[PreProcessorDirective]] +This is probably the most common use of a plugin. + IkiWiki::hook(type => "preprocess", id => "foo", call => \&preprocess); Replace "foo" with the command name that will be used inside brackers for the preprocessor directive. -Each time the directive is processed, the referenced subroutine (`preprocess` in the example above) is called, and is passed named parameters. A +Each time the directive is processed, the referenced function (`preprocess` in the example above) is called, and is passed named parameters. A "page" parameter gives the name of the page that embedded the preprocessor directive. All parameters included in the directive are included -as named parameters as well. Whatever the subroutine returns goes onto the +as named parameters as well. Whatever the function returns goes onto the page in place of the directive. +## Other types of hooks + +Beyond PreProcessorDirectives, Other types of hooks that can be used by plugins include: + +### delete + + IkiWiki::hook(type => "delete", id => "foo", call => \&deletion); + +Each time a page or pages is removed from the wiki, the referenced function is called, and passed the names of the source files that were removed. + +### render + + IkiWiki::hook(type => "render", id => "foo", call => \&update); + +Each time ikiwiki renders a change or addition (but not deletion) of a page to the wiki, the referenced function is called, and passed the name of the source file that was rendered. + ## Error handing in plugins While a plugin can call ikiwiki's error routine for a fatal error, for