User:Dantman/Skinning system/Templates

Data types

 * This section is relatively incomplete and needs a lot more thought on the actual interfaces.

Link extends Url Image extends Url Icon extends Image

Url exposes .href List exposes a .reverse that gives a list that lists things in the opposite order? Grouping exposes it's groups eas as a .key but also lets them be looped over

Context behaviours

 * This section is relatively incomplete and in need of more though.

Html blocks
These behaviours are exhibited when a key is used in a html block, in other words when you use something like .


 * A Html type

General attributes
These behaviours are exhibited when a key is used in a attribute, in other words when you use something like .
 * Html types are invalid.
 * Text types will be escaped and included.

href=""
href="" attributes have these behaviours:
 * If a Link type is used the .href will be used.

src=""
src="" attributes will inherit the same behaviours as a href="" but also have these additional behaviours:
 * If a Image type is used the .src will be used.

Skin keys

 * This list of keys has grown a little stale, some of those have been replaced with some other ideas.

Logical attributes

 * ;) these however are fairly up to date.

If the value is falsy the entire element is omitted.

(boolean attribute)
When present the entire element will be omitted if the contents are empty.

In place of verbose things like this lets you simplify them to.

When present the contents of the element are repeated for each item in the list specified in the value. If inside a context that is a list and the value is omitted the context will be used. In some cases like  the list items will affect the contents in a special way. And as a special case  will be treated as if it had an implicit.

Applies a title attribute with a tooltip specified by the tooltip id in the value. If the value is empty then it'll be extracted from an id attribute if present. If an empty accesskey attribute is present on the element this will also replace that with the relevant accesskey for the id.

As a special case when mw:langorder is used the order of elements within it will be reversed if the language is a rtl language. By default this uses mw:user as the language but a language can be specified, special values used in lang will be accepted. If there are some elements that should be grouped together and not reversed use a null element  to group them together.

For example, this bit based off Vector's simpleSearch uses mw:langorder to put the button before the input in rtl languages. The original vector code had to use two if-rtl's and write the code outputting the searchButton twice.

Special behaviours

 * These too.

A template is not supposed to contain a  tag as the contents of a template go within an already built body and trailer however if you include a body tag in your template the attributes will be extracted and merged with the body built by headElement, classes will be merged rather than replaced.

The lang attribute can accept one of a set of  values which will be replaced with the proper value. The dir attribute will also be replaced if omitted. As an extra if you use a normal language code that MediaWiki understands in  then the dir will be automatically specified.

These are the valid values:
 * - This will use the user's preferred lang. This should be used in parts of the ui where the user's lang is used.
 * - This will use the wiki's content lang. This should be used in blocks if you are explicitly outputting something like a message in the content language.
 * - This will use the page title's lang. The body text is automatically specified but this may be useful in some special locations.

For any  tag encountered through the markup if html5 mode is not set a proper type will be applied to it.

A form with  will be expanded into a search form:
 * A proper action and hidden input will be inserted to make it function as a search form.
 * An input with the name search will be given a search text value, default to type="search", and have tooltip+accesskey added to it.
 * A,  , or   with the name will be expanded to a search button (  will make it fulltext otherwise it'll be a go):
 * Proper tooltip+accesskey will be applied to it.
 * Button text will automatically be filled in.
 * For a  if value is omitted it will be filled.
 * For a  if alt is omitted it will be filled.
 * For a  with one   the  's alt will be filled.
 * For a  with no contents the contents will be filled.