]> sipb.mit.edu Git - ikiwiki.git/blobdiff - doc/plugins/write.mdwn
web commit by JonasSmedegaard: Small typo: "a a" -> "as a"
[ikiwiki.git] / doc / plugins / write.mdwn
index 5be90efdfb73be9a286ce234e0aad5e3fba367a2..abad875685e31b21722bc6415b4c505471ac357a 100644 (file)
@@ -96,9 +96,16 @@ languages to ikiwiki.
 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