]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/commitdiff
edittemplate: only generate a UUID on-demand
authorSimon McVittie <smcv@debian.org>
Tue, 1 Jul 2014 07:23:13 +0000 (08:23 +0100)
committerSimon McVittie <smcv@debian.org>
Mon, 1 Sep 2014 07:54:37 +0000 (08:54 +0100)
If the template doesn't use <TMPL_VAR UUID> there's no point in
incurring any cost.

IkiWiki/Plugin/edittemplate.pm

index 6e8c256da3fdca36addcf8a12a767a6c90d68019..b408dfcac1faf5af44bd03c1c0e4ced5b832107e 100644 (file)
@@ -139,13 +139,15 @@ sub filltemplate ($$) {
 
        $template->param(name => $page);
 
-       eval {
-               require UUID::Tiny;
-               UUID::Tiny->import(':std');
-               my $uuid;
-               $uuid = create_uuid_as_string(UUID_V4());
-               $template->param(uuid => $uuid);
-       };
+       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;
 }