]> sipb.mit.edu Git - ikiwiki.git/commitdiff
Provide the current time to edittemplate.
authorJonathon Anderson <anderbubble@gmail.com>
Sun, 27 Jan 2013 07:38:46 +0000 (10:38 +0300)
committerSimon McVittie <smcv@debian.org>
Mon, 1 Sep 2014 07:54:37 +0000 (08:54 +0100)
The `time` variable contains a fixed-format time, guaranteed suitable
for parsing by timedate.

The `formatted_time` variable contains the same time formatted by
IkiWiki::formattime.

IkiWiki/Plugin/edittemplate.pm
doc/ikiwiki/directive/edittemplate.mdwn

index 571accf1f5c442eb1d0bb1096a79eeb187a6a51d..c61f6336be59abb88243a4ae0059fd872a46109f 100644 (file)
@@ -155,6 +155,10 @@ sub filltemplate ($$) {
                $template->param(uuid => $uuid);
        }
 
+       my $time = time();
+       $template->param(time => IkiWiki::formattime($time, "%Y-%m-%d %H:%M:%S"));
+       $template->param(formatted_time => IkiWiki::formattime($time));
+
        return $template->output;
 }
 
index 63df23914f721b6c6ebf7c1e64216595aa6eb12d..22767de43d3c7efcb9613cdc89d627c2c3c7a9e2 100644 (file)
@@ -29,7 +29,7 @@ something like:
 The template page can also contain [[!cpan HTML::Template]] directives,
 like other ikiwiki [[templates]].
 
-Two variables might be set:
+Four variables might be set:
 
 * `<TMPL_VAR name>` is replaced with the name of the page being
   created.
@@ -37,4 +37,10 @@ Two variables might be set:
 * `<TMPL_VAR uuid>` is replaced with a version 4 (random) UUID.
   (Requires the `UUID::Tiny` Perl module if not running on Linux.)
 
+* `<TMPL_VAR time>` is replaced with the current (template generation)
+  time, using a fixed format, `%Y-%m-%d %H:%M:%S`.
+
+* `<TMPL_VAR formatted_time` is replaced with the current (template
+  generation) time, formatted by IkiWiki.
+
 [[!meta robots="noindex, follow"]]