summaryrefslogtreecommitdiff
path: root/doc/plugins/write.mdwn
diff options
context:
space:
mode:
Diffstat (limited to 'doc/plugins/write.mdwn')
-rw-r--r--doc/plugins/write.mdwn22
1 files changed, 20 insertions, 2 deletions
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