summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess <joey@kodama.kitenet.net>2008-07-10 15:25:05 -0400
committerJoey Hess <joey@kodama.kitenet.net>2008-07-10 15:25:42 -0400
commitdcab5e2e48275dbeb3bf514c68826e73abed08bc (patch)
treeef2c1e12d0fda33da1fc0baa9bff6166018a27a7
parentc52493422bfa0b5c58c6f952a77c769ac01f11f3 (diff)
template: Add support for a BASENAME variable.
-rw-r--r--IkiWiki/Plugin/template.pm2
-rw-r--r--debian/changelog3
-rw-r--r--doc/templates.mdwn3
-rw-r--r--doc/todo/Give_access_to_more_TMPL__95__VAR_variables_in_templates_inserted_by_the_template_plugin.mdwn4
4 files changed, 11 insertions, 1 deletions
diff --git a/IkiWiki/Plugin/template.pm b/IkiWiki/Plugin/template.pm
index a6e34fcc9..aa1f57c07 100644
--- a/IkiWiki/Plugin/template.pm
+++ b/IkiWiki/Plugin/template.pm
@@ -45,6 +45,8 @@ sub preprocess (@) { #{{{
return "[[template ".gettext("failed to process:")." $@]]";
}
+ $params{basename}=IkiWiki::basename($params{page});
+
foreach my $param (keys %params) {
if ($template->query(name => $param)) {
$template->param($param =>
diff --git a/debian/changelog b/debian/changelog
index 5b85ce598..68c70f3f4 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -9,6 +9,9 @@ ikiwiki (2.54) UNRELEASED; urgency=low
* ikiwiki-transition: Fix command-line processing so the prefix_directives
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
ikiwiki (2.53) unstable; urgency=low
diff --git a/doc/templates.mdwn b/doc/templates.mdwn
index 58d5d1146..b40e865e1 100644
--- a/doc/templates.mdwn
+++ b/doc/templates.mdwn
@@ -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
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
in the value will first be converted to html.
* To insert the raw value of a variable, with wiki markup not yet converted
diff --git a/doc/todo/Give_access_to_more_TMPL__95__VAR_variables_in_templates_inserted_by_the_template_plugin.mdwn b/doc/todo/Give_access_to_more_TMPL__95__VAR_variables_in_templates_inserted_by_the_template_plugin.mdwn
index eaa7cb2b6..57e05b76b 100644
--- a/doc/todo/Give_access_to_more_TMPL__95__VAR_variables_in_templates_inserted_by_the_template_plugin.mdwn
+++ b/doc/todo/Give_access_to_more_TMPL__95__VAR_variables_in_templates_inserted_by_the_template_plugin.mdwn
@@ -88,7 +88,7 @@ avoid the ad-hoc plugin solution.
most possible of these pages.
> 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
> index a6e34fc..bb9dd8d 100644
@@ -105,3 +105,5 @@ most possible of these pages.
> $template->output));
>
> -- intrigeri
+
+> Thanks for taking the trouble to develop a patch. [[done]] --[[Joey]]