Provide a UUID in edittemplate templates.

I want to make GUIDs for my RSS feeds that don't change when I move
pages around.  To that end, I've used UUID::Tiny to generate a
version 4 (random) UUID that is presented in a `uuid` variable in
the template.

At that point, you can do something like this:

    [[!meta guid="urn:uuid:<TMPL_VAR uuid>"]]
master
Jonathon Anderson 2013-01-25 08:42:23 +03:00 committed by Simon McVittie
parent d5f5313925
commit 7aa10a2952
2 changed files with 17 additions and 3 deletions

View File

@ -139,6 +139,14 @@ sub filltemplate ($$) {
$template->param(name => $page); $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);
};
return $template->output; return $template->output;
} }

View File

@ -27,8 +27,14 @@ something like:
Details: Details:
The template page can also contain [[!cpan HTML::Template]] directives, The template page can also contain [[!cpan HTML::Template]] directives,
like other ikiwiki [[templates]]. Currently only one variable is like other ikiwiki [[templates]].
set: `<TMPL_VAR name>` is replaced with the name of the page being
created. Two variables might be set:
* `<TMPL_VAR name>` is replaced with the name of the page being
created.
* `<TMPL_VAR uuid>` is replaced with a version 4 (random) UUID.
(Requires the `UUID::Tiny` Perl module.)
[[!meta robots="noindex, follow"]] [[!meta robots="noindex, follow"]]