From f00e5a8a89d47c6dee8a63b1ab9c6d89de9a61cd Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 10 Jul 2008 04:32:24 -0400 Subject: web commit by intrigeri: removed misunderstood references to pagetemplate, added patch against plugins/template --- ..._templates_inserted_by_the_template_plugin.mdwn | 35 ++++++++++++++-------- 1 file changed, 23 insertions(+), 12 deletions(-) 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 6f430975e..eaa7cb2b6 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 @@ -1,4 +1,4 @@ -[[tag wishlist]] +[[tag wishlist patch]] # Context @@ -54,7 +54,7 @@ of the pages tagged d1. My current plan is : -- thanks to the pagetemplate plugin, `/view/dev/*` and `/view/howto/*` would be assigned two custom templates, containing respectively `\[[template id=dev_direction]]` and `\[[template id=howto_usage]]` +- thanks to the edittemplate plugin, `/view/dev/*` and `/view/howto/*` would contain respectively `\[[template id=dev_direction]]` and `\[[template id=howto_usage]]` - `/templates/dev_direction.mdwn` and `/templates/howto_usage.mdwn` would use `\[[!map ...]]` directives to build their views # My issue @@ -84,13 +84,24 @@ preprocessor directives already *almost* do what I need, I'd like to avoid the ad-hoc plugin solution. (Adding a parameter such as `name=d1` in every `/view/dev/d*.mdwn` and -`/view/howto/u*.mdwn` page is not an option : there may be quite -a few, that's why I intend to use the pagetemplate plugin in the first -place to assign them a common template.) - -More or less OT: I've not checked the compatibility of pagetemplate -and template plugins yet; can a template (`*.tmpl`), assigned by -pagetemplate, itself call a template (`*.mdwn`) managed by the -template plugin ? The hooks call order tends to make me think it is -not possible, which anyway would ruin my current plan. - +`/view/howto/u*.mdwn` page is not an option : I want to factorize the +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]] : + +> diff --git a/IkiWiki/Plugin/template.pm b/IkiWiki/Plugin/template.pm +> index a6e34fc..bb9dd8d 100644 +> --- a/IkiWiki/Plugin/template.pm +> +++ b/IkiWiki/Plugin/template.pm +> @@ -57,6 +57,8 @@ sub preprocess (@) { #{{{ +> } +> } +> +> + $template->param("basename" => (split("/", $params{page}))[-1]); +> + +> return IkiWiki::preprocess($params{page}, $params{destpage}, +> IkiWiki::filter($params{page}, $params{destpage}, +> $template->output)); +> +> -- intrigeri -- cgit v1.2.3