template: Add support for a BASENAME variable.

master
Joey Hess 2008-07-10 15:25:05 -04:00
parent c52493422b
commit dcab5e2e48
4 changed files with 11 additions and 1 deletions

View File

@ -45,6 +45,8 @@ sub preprocess (@) { #{{{
return "[[template ".gettext("failed to process:")." $@]]"; return "[[template ".gettext("failed to process:")." $@]]";
} }
$params{basename}=IkiWiki::basename($params{page});
foreach my $param (keys %params) { foreach my $param (keys %params) {
if ($template->query(name => $param)) { if ($template->query(name => $param)) {
$template->param($param => $template->param($param =>

3
debian/changelog vendored
View File

@ -9,6 +9,9 @@ ikiwiki (2.54) UNRELEASED; urgency=low
* ikiwiki-transition: Fix command-line processing so the prefix_directives * ikiwiki-transition: Fix command-line processing so the prefix_directives
transition works again. transition works again.
[ Joey Hess ]
* template: Add support for a BASENAME variable.
-- Josh Triplett <josh@freedesktop.org> Wed, 09 Jul 2008 21:30:33 -0700 -- Josh Triplett <josh@freedesktop.org> Wed, 09 Jul 2008 21:30:33 -0700
ikiwiki (2.53) unstable; urgency=low ikiwiki (2.53) unstable; urgency=low

View File

@ -50,6 +50,9 @@ module, which allows for some fairly complex things to be done. Consult its
documentation for the full syntax, but all you really need to know are a documentation for the full syntax, but all you really need to know are a
few things: few things:
* Each parameter you pass to the template directive will generate a
template variable. There are also some pre-defined variables like PAGE
and BASENAME.
* To insert the value of a variable, use `<TMPL_VAR variable>`. Wiki markup * To insert the value of a variable, use `<TMPL_VAR variable>`. Wiki markup
in the value will first be converted to html. in the value will first be converted to html.
* To insert the raw value of a variable, with wiki markup not yet converted * To insert the raw value of a variable, with wiki markup not yet converted

View File

@ -88,7 +88,7 @@ avoid the ad-hoc plugin solution.
most possible of these pages. most possible of these pages.
> The following patch adds a `basename` `TMPL_VAR` variable that can be > The following patch adds a `basename` `TMPL_VAR` variable that can be
> used in the templates inserted by [[template plugin]] : > used in the templates inserted by \[[template plugin]] :
> diff --git a/IkiWiki/Plugin/template.pm b/IkiWiki/Plugin/template.pm > diff --git a/IkiWiki/Plugin/template.pm b/IkiWiki/Plugin/template.pm
> index a6e34fc..bb9dd8d 100644 > index a6e34fc..bb9dd8d 100644
@ -105,3 +105,5 @@ most possible of these pages.
> $template->output)); > $template->output));
> >
> -- intrigeri > -- intrigeri
> Thanks for taking the trouble to develop a patch. [[done]] --[[Joey]]