X-Git-Url: http://git.tremily.us/?a=blobdiff_plain;f=doc%2Fplugins%2Fwrite.mdwn;h=abad875685e31b21722bc6415b4c505471ac357a;hb=20eacc2c1f74d0ab617dca36378a35920e313a23;hp=515c4d90d6091766a90b01a498507bd47bf99f4a;hpb=54541869392f162bb195b8b67814ef0a394c1961;p=ikiwiki.git diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index 515c4d90d..abad87568 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -55,7 +55,8 @@ Note that if the [[htmlscrubber]] is enabled, html in [[PreProcessorDirective]] output is sanitised, which may limit what your plugin can do. Also, the rest of the page content is not in html format at preprocessor time. Text output by a preprocessor directive will be passed -through markdown along with the rest of the page. +through markdown (or whatever engine is used to htmlize the page) along +with the rest of the page. # Other types of hooks @@ -79,6 +80,15 @@ Runs on the raw source of a page, before anything else touches it, and can make arbitrary changes. The function is passed named parameters `page` and `content` and should return the filtered content. +## htmlize + + IkiWiki::hook(type => "htmlize", id => "ext", call => \&filter); + +Runs on the raw source of a page and turns it into html. The id parameter +specifies the filename extension that a file must have to be htmlized using +this plugin. This is how you can add support for new and exciting markup +languages to ikiwiki. + ## pagetemplate IkiWiki::hook(type => "pagetemplate", id => "foo", call => \&pagetemplate); @@ -86,9 +96,16 @@ make arbitrary changes. The function is passed named parameters `page` and Each time a page is rendered, a [[template|templates]] is filled out. This hook allows modifying that template. The function is passed the name of the page, and a `HTML::Template` object that is the template that will -be used to generate the page. It can manipulate that template, the most -common thing to do is probably to call $template->param() to add a new -custom parameter to the template. +be used to generate the page. It can manipulate that template object. + +The most common thing to do is probably to call $template->param() to add +a new custom parameter to the template. Note that in order to be robust, +it's a good idea to check whether the template has a variable before trying +to set it, as setting a variable that's not present is an error. + + if ($template->query(name => 'foo')) { + $template->param("foo" => "bar"); + } ## sanitize