Template:Data: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
No edit summary
No edit summary
Line 29: Line 29:
</templatedata>
</templatedata>


This template is based on the [http://kol.coldfront.net/thekolwiki/index.php/Template:Data Template:Data] page.
This template is based on the [http://kol.coldfront.net/thekolwiki/index.php/Template:Data Template:Data] page in the KoL wiki.


==What is a Data Page?==
==What is a Data Page?==

Revision as of 21:02, 18 December 2020


Utility template that extracts a field from a data page.

Template parameters[Edit template data]

ParameterDescriptionTypeStatus
Page name1

Name of the data page to extract the data from.

Example
visit_url
Page namerequired
Field name2

Name of the field to extract from the source page

Example
function1.parameter1
Linerequired
Default value3

Default value if the page does not contain the given field, or the field is empty

Example
no_name
Stringoptional

This template is based on the Template:Data page in the KoL wiki.

What is a Data Page?

Suppose a page named "XYZ" contains the following wikitext:

<onlyinclude>{{{{{format|DefaultTemplate}}}
|param1=abc
|foo=bar
|some.property=some value
|empty_value=
|{{{1|}}}
}}</onlyinclude>

Any page that contains code like this is a data page. A data page cannot render itself, but instead feeds its parameters to a rendering template ("DefaultTemplate" in this example) which is responsible for rendering the page.

The Template:Data template can extract individual fields from a data page, like this:

Wiki markup Result
{{data|XYZ|param1}}
abc
{{data|XYZ|foo}}
bar
{{data|XYZ|some.property}}
some value
{{data|XYZ|empty_value}}
{{data|XYZ|empty_value|default value}}
default value
{{data|XYZ|value that does not exist|default value}}
default value