diff options
author | Jonathon Anderson <anderbubble@gmail.com> | 2013-01-25 08:42:23 +0300 |
---|---|---|
committer | Simon McVittie <smcv@debian.org> | 2014-09-01 08:54:37 +0100 |
commit | 7aa10a2952a0d0ee8543f575966f7e4a780c993c (patch) | |
tree | 783fc89f0344a12fadffea9305e689700b11d300 | |
parent | d5f53139259f57e6554614cede22ed08a59bfce7 (diff) | |
download | ikiwiki-7aa10a2952a0d0ee8543f575966f7e4a780c993c.tar ikiwiki-7aa10a2952a0d0ee8543f575966f7e4a780c993c.tar.gz |
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>"]]
-rw-r--r-- | IkiWiki/Plugin/edittemplate.pm | 8 | ||||
-rw-r--r-- | doc/ikiwiki/directive/edittemplate.mdwn | 12 |
2 files changed, 17 insertions, 3 deletions
diff --git a/IkiWiki/Plugin/edittemplate.pm b/IkiWiki/Plugin/edittemplate.pm index e3ce5e3d9..6e8c256da 100644 --- a/IkiWiki/Plugin/edittemplate.pm +++ b/IkiWiki/Plugin/edittemplate.pm @@ -139,6 +139,14 @@ 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); + }; + return $template->output; } diff --git a/doc/ikiwiki/directive/edittemplate.mdwn b/doc/ikiwiki/directive/edittemplate.mdwn index a6f301dd3..151fd203a 100644 --- a/doc/ikiwiki/directive/edittemplate.mdwn +++ b/doc/ikiwiki/directive/edittemplate.mdwn @@ -27,8 +27,14 @@ something like: Details: The template page can also contain [[!cpan HTML::Template]] directives, -like other ikiwiki [[templates]]. Currently only one variable is -set: `<TMPL_VAR name>` is replaced with the name of the page being -created. +like other ikiwiki [[templates]]. + +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"]] |