FANDOM


Description

This template is used to store shared data in the data pages. Its purpose is to avoid data duplication as much as possible. As the shared data may be retrieved in many places, they should stay concise and usable in many forms, so it’s better (when possible) to store for instance the name of an article ("ABC") rather than the link to that article ("[[ABC]]"), as it’s far more easier to create the link from the name than the opposite.

This doc covers both the storing and retrieving of data.

Storing data

Syntax

When creating a data sub-page (e.g. Dagger/data), it should look like:

{{Data|{{{1|}}}|{{{2|}}}|{{{3|}}}|{{{4|}}}|{{{$|}}}
 | key1       = value1
 | key2       = value2
 | anotherkey = anothervalue
}}
Notes
  • The first line is required to have that exact syntax, without any additional new line or white space that might break the expected behavior.
  • No additional text (even categorization), new line or white space shall be added before or after the template. The only exception is the single new line automatically appended at the end of the page.

Retrieving data

Syntax

{{:PAGENAME/data|prefix|key name|suffix|default value}}

Samples

If we wanted the health value of Goo;

{{:Goo/data||health}}

results in...

80

The 4th parameter ("default value") can be used to give a default value if the 2nd parameter ("key name") doesn’t match a key name in the data store.

The Goo can become {{:Goo/data||mutation||no other mutation}}.

results in...

The Goo can become no other mutation.

The 1st and 3rd parameters ("prefix" and "suffix") can be used to add information before and after the value, but only if it exists in the data store.

The Marsupial rat can become {{:Marsupial_rat/data|the mutated |mutation| (beware!)|no other mutation}}.

results in...

The Marsupial rat can become the mutated Albino rat (beware!).

Testing data

Syntax

  • {{:PAGENAME/data||key name|if present|$=$}}
  • {{:PAGENAME/data||key name|if present|if absent|$=$}}

Samples

If anything is given in the $ parameter (standard use is "$=$", but any other non-empty value may be used, like "$=test" for instance), then the 3rd parameter ("if present") is displayed if the 2nd parameter ("key name") matches a key name in the data store; if it doesn’t match a key name in the data store, the 4th parameter ("if absent") is displayed instead. In any case, the associated value won’t be returned.

The Marsupial rat {{:Marsupial_rat/data||mutation|can|cannot|$=$}} mutate
The Goo {{:Goo/data||mutation|can|cannot|$=$}} mutate

results in...

The Marsupial rat can mutate
The Goo cannot mutate
Community content is available under CC-BY-SA unless otherwise noted.