X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/b9b4bfd29dc1b106c133402a3c4a97aeaf07fe2e..cf1290eb464f1256aa5c12d973fff774e4f83e5e:/doc/todo/allow_TMPL__95__LOOP_in_template_directives.mdwn diff --git a/doc/todo/allow_TMPL__95__LOOP_in_template_directives.mdwn b/doc/todo/allow_TMPL__95__LOOP_in_template_directives.mdwn index a8d100551..890c4cf4b 100644 --- a/doc/todo/allow_TMPL__95__LOOP_in_template_directives.mdwn +++ b/doc/todo/allow_TMPL__95__LOOP_in_template_directives.mdwn @@ -1,15 +1,33 @@ -[[!tag patch]] +[[!tag patch todo]] -[[!templte id="note" text=""" +[[!template id="note" text=""" Simply copied this from my website [[http://www.camco.ie/code/ikiwiki,3.20120202,20120313a/]] feel free to reformat / delete"""]] The following re-write allows for multiple definitions of the -same tag value in a template definition. This, in turn, allows -us to use TMPL_LOOPS in our template directives; all-be-it in a +same tag value in a [[plugins/template]] definition. This, in turn, allows +us to use TMPL_LOOPS in our [[ikiwiki/directive/template]] directives; all-be-it in a rather limited way. +> I'm willing to consider such a feature, but it needs to be presented in +> the form of a patch that is reviewable, not a gratuitous rewrite. +> --[[Joey]] + +>> Yes, my apologies for that. The two worker functions `mktmpl_hash` +and `proc_tmpl_hash` are new. The `preprocess` function then starts +by arranging the parameters into an array. This array is passed to the +`mktmpl_hash` and it creates a hash, suitable for passing into the +HTML::Template directly. The `proc_tmpl_hash` then walks the hash +structure and processes the parameters. + +>> I know ... you weren't looking for an explanation, just a patch +... totally understand. Point I'm trying to make, it's a 90% re-write +anyway (and my `style(8)` will probably piss most people off). + +>> Anyway, would love to contribute so will try to get to doing this +"correctly" and post as a patch. + I would, personally, only use this feature for very basic loops and, although nested loops *might* be possible (with a little more tinkering) it think any attempt would be better served by @@ -27,6 +45,8 @@ head-aches. Anyway it didn't make sense to post the patch since everything's changed now. """]] +NB: this *should* be 100% backwards compatible. + # `lib/perl5/IkiWiki/Plugin/template.pm` [[!format perl """ @@ -190,7 +210,7 @@ everything's changed now. my $page = $params{page}->[$#{$params{page}}] ; my $destpage = $params{destpage}->[$#{$params{destpage}}] ; # ... and an essential one for the production pass - $params{basename} = IkiWiki::basename($page) ; + $params{basename} = [ IkiWiki::basename($page) ] ; # load the template my $template ; @@ -254,5 +274,5 @@ everything's changed now. data0="cell0:0" data1="cell0:1" data0="cell1:0" - data0="cell1:1" + data1="cell1:1" ]]