[Wikipedia-l] Templates and key-value pairs

kelvSYC kelvsyc at shaw.ca
Thu Oct 28 06:25:17 UTC 2004


I know that this idea, as is, will probably be rejected on the grounds 
of it being applicable to only a small minority of articles on en (or 
any other pedia) and of little use in any other Wikimedia project, but 
if I throw it out here, perhaps some generalization of this idea could 
be created.

Here goes:

In the world of sports, teams are often abbreviated in some manner.  
For example, in the [[National Hockey League]], LA refers to the [[Los 
Angeles Kings]] while in [[Major League Baseball]], LA refers to the 
[[Los Angeles Dodgers]].  Because of the recent proliferation of stuff 
that requires an abbreviation be linked to a team (eg. such as an 
article about a sporting event), you'd like abbreviations be linked to 
a team's article (ie. in an article about baseball, you'd want [[Los 
Angeles Dodgers|LA]]).  However, this can be cumbersome and 
time-consuming, especially for large amounts of articles or teams (eg. 
the ongoing project where one article is given for each World Series).  
What I propose is some form of "key-value pairing" to the way templates 
work.  Granted, all this can be done without the use of this "switch 
statement" by the use of multiple template pages, so this is in the 
interest of "keeping it all in the same page" or "keeping things 
relatively compact".

The way it would work is if you have a template such as {{MLB|LA}}, for 
example, the template would expand to [[Los Angeles Dodgers|LA]].  In 
each template page, you'd have a set of keys and a set of values that 
these keys would refer to.  For example:

Template:MLB
{{{
ANA -> [[Anaheim Angels|ANA]],
BOS -> [[Boston Red Sox|BOS]],
...
TEX -> [[Texas Rangers|TEX]],
TOR -> [[Toronto Blue Jays|TOR]]
}}}

Then, when a template is called, a key is specified, and the wiki 
software would print the value associated with the key.  Should no key 
be specified, or an invalid key is specified, some kind of fallback 
behaviour would kick in.

You can, of course, have additional template parameters in the normal 
sense.  For example,

Template:a
{{{b -> [[B|{{{c}}}]]}}}

You could have something like {{a|b|c=foo}}} and it would print out 
[[B|foo]].

As I have stated above, this is completely optional and can be 
implemented in other ways, but this idea is just for the sake of 
convienience.  What are your thoughts on this idea?




More information about the Wikipedia-l mailing list