edittemplate: only generate a UUID on-demand

If the template doesn't use <TMPL_VAR UUID> there's no point in
incurring any cost.
master
Simon McVittie 2014-07-01 08:23:13 +01:00
parent 7aa10a2952
commit 4a11dc4d16
1 changed files with 9 additions and 7 deletions

View File

@ -139,13 +139,15 @@ sub filltemplate ($$) {
$template->param(name => $page); $template->param(name => $page);
eval { if ($template->query(name => 'uuid')) {
require UUID::Tiny; eval {
UUID::Tiny->import(':std'); require UUID::Tiny;
my $uuid; UUID::Tiny->import(':std');
$uuid = create_uuid_as_string(UUID_V4()); my $uuid;
$template->param(uuid => $uuid); $uuid = create_uuid_as_string(UUID_V4());
}; $template->param(uuid => $uuid);
};
}
return $template->output; return $template->output;
} }