Extension:HashTables

HashTables provides your wiki with several new parser functions for creating and operating hash tables. Hash tables are very similar to arrays which can be used via Extension:ArrayExtension. HashTables is featuring the function parameterstohash which allows to store all parameters given to a template and to use those in other templates due to the fact that all hash tables are global.

Functions
This module defines the following functions:

hashdefine
This function defines a new hash table identified by key using a list of values separated by a itemsDelimiter (default ). All items of the hash table have an item key to identify a value. This item key and its value must be separated by the innerDelimiter (default ). In case the values parameter is empty a void hash table will be created.

Syntax:

Notes:
 * Hash table items must be unique. In case a item key appears more than once in the values list only the last item will end up in the hash table.
 * A empty string as item key is technically possible. Item values can be empty strings as well.

parameterstohash
This function will create a new hash table identified by key. The items will be all the template parameters delivered to the current template which is calling the function.

Syntax:

This can be very usefull if you with to define a generic template which should be configurable by other templates which should be aware of the parameters given to the main template.

hashprint
This function prints all the values of a hash table identified by key separated by a delimiter. It is possible to control the output by defining a subject where all appearances of a keyPattern for the hash table keys and a valuePattern for their values will be replaced with either the key or the value of the current hash table item.

Syntax:

Example:

hashvalue
This function prints the hash table item value of a given hash table itemKey. In case the key doesn't exist or the value of the item is a void string the default value will be returned.

Syntax:

hashsize
This function returns the number of items of a hash table identified by key. In case the table doesn't exist the function will return a void string. The return value for existing but void hash tables is.

Syntax:

hashreset
This function delets all or some defined hash tables. This is good to free up some memory when a hash table is obsolete.

Syntax:

Note: The syntax of this function is different from the ArrayExtensions arrayreset function.

Important Notes
When using hash tables, you should be aware of the following points:
 * Hash tables are always global. If you create a hash table abc in template X the hash table abc will be available in all other templates which are called after this event. Hash tables, Arrays and Variables all have a global scope for their values.
 * When you call a template Z like  without any parameters and the template is using hash tables which should change on every call of the template, this propably won't work. MediaWiki uses a cache for templates called without parameters so the code will be executed only once. MW assumes that those templates are not dynamic. To avoid this cache you can simply call  (void parameter 1) and the cache will be disabled.

Change Log
the latest HashTables extension has been tested on MediaWiki version 1.15

 History: 


 * May 30, 2010 -- Version 0.1: First version of HashTables featuring the functions 'hashdefine', 'hashvalue', 'hashsize', 'hashprint', 'hashreset' and 'parameterstohash'.