gamma wrote
I'm not fully sure I understand all the bits of what your plugin would be capable to do, but
http://www.dokuwiki.org/plugin:page-templater sound similar to your approach … or what else would the plugin be able to do?
Not exactly. The mechanism used by the
page-templater[/m] plugin is more akin to what DokuWiki templates/skins do [m][1] in that they "filter" the content o a wikipage and apply it *to* a template.
My plugin would be different in that it would work with a mechanic similar to that of
Mediawiki-style templates (includes)
[2][/m], or, aiming closer to home, the [m]include[/m] plugin [m][3]. That is, instead of applying the current page
to a templater, I apply a template
to the current page. Parameters that will be substituted at the included template can be specified. The net result is that the current page now includes the (parsed) content of the template with the substitutions specified.
For example, a template for use with my plugin could be a (otherwise normal) wikipage with content like this:
wiki:userlink
{#if: @NAME@~user|[[:user:@NAME@]]|[[Google>@NAME]]#}
When applied and the parameters substituted, this plugin could function as a means to display a link to the user @NAME@ if NAME is valid username in the current DokuWiki installation, or otherwise throw in a Google link to search for that person (if it's a full name like in the form Randall Munroe, maybe).
In case of doubt, you can check in or try to contact {{subst>wiki:personlink|NAME=ryan.chappelle}}.
A more elaborate example: let's say you want to build a table of countries, their adopted currencies and their
flags, but you don't know how many countries you're going to get, you simply know where to get the information from. (For added bonus in this example, I'll assume all the flags are available as uploaded media fiiles) Then, it's as simple as to create a template that will do a
single row of the table for you, and invoke as necessary:
wiki:countrytblrow
^ {{:images:flag_@COUNTRY@.png}}\\ [[wp>@COUNTRY@]] | @CURNAME@ -- [[Google>1 @CUR@ to EUR|check]] |
With this, you can create the table live by just prepending an adequate header:
The following is a list of countries to which we are exporting our DokuWiki products:
^ Country Name ^ Exchange Rate\\ (check at Google) |
{{subst>wiki:countrytblrow|COUNTRY=Chile|CUR=CLP|CURNAME=Chilean peso}}
{{subst>wiki:countrytblrow|COUNTRY=Mexico|CUR=MXN|CURNAME=Mexican peso}}
{{subst>wiki:countrytblrow|COUNTRY=Moldova|CUR=MDL|CURNAME=Moldovan leu}}
{{subst>wiki:countrytblrow|COUNTRY=Poland|CUR=PLN|CURNAME=Złoty}}
^^ Table of countries and currencies as of Jan, 2010. ^
The plugin will take care of creating the right wikistructure for this, by replacing each call to the plugin with the wikicode syntax the template generates (and thus the rendering remains a matter of the "current" page). In fact, the result would have looked exactly like this wikicode had been used on the original page,
both visually and code-wise:
^ Country Name ^ Exchange Rate\\ (check at Google) |
^ {{:images:flag_Chile.png}}\\ [[wp>Chile]] | Chilean Peso -- [[Google>1 CLP to EUR|check]] |
^ {{:images:flag_Mexico.png}}\\ [[wp>Mexico]] | Mexican Peso -- [[Google>1 MXN to EUR|check]] |
^ {{:images:flag_Moldova.png}}\\ [[wp>Moldova]] | Moldovan leu -- [[Google>1 MDL to EUR|check]] |
^ {{:images:flag_Poland.png}}\\ [[wp>Poland]] | Złoty -- [[Google>1 PLN to EUR|check]] |
^^ Table of countries and currencies as of Jan, 2010. ^
The result will thus be a normal table. Note that due to the syntax modes used and the parsing method, the
templater plugin can not currently generate content this way, which is one of the reasons why I am trying to create this plugin. That, and the basic logic.
I hope that this further clears the issue.
I would like to hear more feedback on the usefulness and want or need for this kind of plugin.
[1] DokuWiki templates (skin feature):
http://www.dokuwiki.org/template
[2] Include plugin:
[3] Mediawiki templates (include feature):
http://www.mediawiki.org/wiki/Help:Templates