We could avoid most of the hassle of HTML tables with a relatively simple template system. The user of a template would just have to enter key/value pairs and the software would do the rest.
Let's take the country tables as an example. This is a table that essentially looks the same on every country page, with different contents. So we could have
[[Template:Country table]]
which would contain the table with a special syntax for variable dentifiers and conditional expressions:
<table border="0" width="200"> <<Flag && Coat of arms?? <tr><td> ::Flag:: </td><td> ::Coat of arms:: </td> </tr>
<<Flag && !Coat of arms?? <tr><td colspan=2> ::Flag:: </td> </tr>
<tr><td> Official language </td> <td> ::Language:: </td> </tr> <<President? <tr><td> President </td> <td> ::President:: </td> </tr>
........... </table>
The above contains two important elements:
* variables (enclosed in ::name::) These contain text that is defined by the template user and inserted into the template when it is used. * condition blocks (enclosed in <<..?? .. >>) These determine under which conditions the respective text from the template is to be inserted; that is, which variables have to be set or unset.
Now any country page could use the template defined above like this:
<Template:Country table> Flag:: [[Image:Flag_germany.jpg]] Coat of arms:: [[Image:Coat_of_arms_Germany.jpg]] Language:: German President:: Johannes Rau ... </template>
Similarly for taxonomy tables
<Template:Taxonomy table> Name:: Amaryllis Kingdom:: Plantae Division:: Magnoliophyta Class:: Lilliopsida ... </template>
For navigation tables:
<Template:British Monarch navigation> Preceded by:: George VI Heir apparent:: Charles, Prince of Wales </template>
This is easy to use and easy to edit, but generates nice looking, correctly aligned tables. It could also be used for general image formatting:
<Template:Image right> Image:: Foo.jpg Width:: 420 Caption:: My image </template>
using the following template, for example:
<table border=0 width="::Width::" align="right"> <tr><td> [[Image:::Image::]] <br> ''::Caption::'' </td></tr> </table>
Most of the code required for this feature is simple search/replace stuff, only the conditional expression parsing is somewhat more complex, but also offers a lot of power to handle subtle variations in tables. The template syntax could also provide functionality for iterations, or these could be implicitly generated by simply repeating a variable during the template use:
[[Template:List table]]
<table border=0> <<Item?? <tr><td>::Item::</td></tr>
</table>
->
<Template:List table> Item::Foo Item::Bar Item::Baz </template>
->
<table border="0"> <tr><td>Foo</td></tr> <tr><td>Bar</td></tr> <tr><td>Baz</td></tr> </table>
That is, the conditional expression Item?? would automatically run an iteration of the enclosing block if there is more than one item (whereas without the conditional expression, only one item would be used).
Syntax likes and dislikes aside, I'd be interested in what you think about such a system.
Regards,
Erik
On Sat, Jun 14, 2003 at 08:06:00AM +0200, Erik Moeller wrote:
Syntax likes and dislikes aside, I'd be interested in what you think about such a system.
Since I proposed something similar (with a completely different syntax) in http://mail.wikipedia.org/pipermail/wikipedia-l/2003-May/010141.html and http://mail.wikipedia.org/pipermail/wikipedia-l/2003-May/010168.html , you can count me as a proponent.
JeLuF
--- Erik Moeller erik_moeller@gmx.de wrote:
We could avoid most of the hassle of HTML tables with a relatively simple template system. The user of a template would just have to enter key/value pairs and the software would do the rest.
Yes, that would be nice.
<Template:Country table> Flag:: [[Image:Flag_germany.jpg]] Coat of arms:: [[Image:Coat_of_arms_Germany.jpg]] Language:: German President:: Johannes Rau ...
</template>
I think a single colon looks a bit simpler and should be sufficient here, if you require the whole variable text to be in one line. Or alternatively you could use XML style arguments.
Axel
__________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com
wikitech-l@lists.wikimedia.org