]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/edittemplate.pm
edittemplate: only generate a UUID on-demand
[ikiwiki.git] / IkiWiki / Plugin / edittemplate.pm
index 061242fd82c1f1a76251dac12f8017821688a2a1..b408dfcac1faf5af44bd03c1c0e4ced5b832107e 100644 (file)
@@ -130,13 +130,25 @@ sub filltemplate ($$) {
                $template=template("/".$template_page);
        };
        if ($@) {
+               # gettext can clobber $@
+               my $error = $@;
                # Indicate that the earlier preprocessor directive set 
                # up a template that doesn't work.
-               return "[[!pagetemplate ".gettext("failed to process template:")." $@]]";
+               return "[[!edittemplate ".gettext("failed to process template:")." $error]]";
        }
 
        $template->param(name => $page);
 
+       if ($template->query(name => 'uuid')) {
+               eval {
+                       require UUID::Tiny;
+                       UUID::Tiny->import(':std');
+                       my $uuid;
+                       $uuid = create_uuid_as_string(UUID_V4());
+                       $template->param(uuid => $uuid);
+               };
+       }
+
        return $template->output;
 }