Help:UsingData

The UsingData extension adds parser functions which allow pages to specify and query "data" using template-like syntax, without affecting normal content transclusion.

In the context of this extension, "data" consists of key-value pairs, similar to named template arguments, which can be associated with a page by using the #data parser function directly on that page, and accessed by using the #using and #usingarg parser functions elsewhere on the wiki.

Specifying data
To specify the list of key-value pairs associated with a page, use the #data parser function directly on the desired page. The data function outputs the result of passing the specified arguments to the specified template.


 * Template : Name of the template (article title, assumed to be in the Template namespace by default) to pass the specified arguments to to produce returned output. If you do not want to produce visible output (and only wish to specify the key-value pairs), Blank is an appropriate choice.
 * ... : Any number of named template arguments (e.g. "|foo=bar|baz=qux") to associate with the page.

To work correctly, the #data function must be placed directly on the associated page (as it acts only as a template call when transcluded), and not be wrapped in &lt;includeonly> tags.

Querying data
To use the data specified on some page, you can use the #using and #usingarg parser functions.


 * Page : Page to use data from (article title, assumed to be in the Main namespace by default).
 * Template : Template to parse with the data from Page passed as arguments (article title, assumed to be in the Template namespace by default).
 * DefaultValue : Optional - If there's no #data on Page, and this value is specified, #using will return this instead of parsing Template.
 * ... : Optional - Any additional named arguments to pass to Template, overriding any data from Page.


 * Page : Page to use data from (article title, assumed to be in the Main namespace by default).
 * Arg : Data key to query; the associated value on Page is returned if defined.
 * DefaultValue : Optional - If Page does not define Arg, this value will be returned instead (an empty string by default).

Additional arguments
When invoked through the #data/#using functions, templates are passed these additional arguments, which override any others with the same name:
 * : Canonical page title of the page passed data is defined on (or queried from).
 * : data-source, escaped for comparison with.
 * : An empty string if the #using call could not locate any #data tags on the source page; a non-empty string otherwise.

Examples

 * Test Item (example) : Use #data to define item-related data directly on the item page; this doubles as a call to a template that generates the item tooltip for the page.
 * Template : Link/format : A template generates a formatted link based on passed (named) arguments, matching those used in the #data call above.


 * Template : Link : Hides #using: syntax from users, instructs the parser to parse Template:Link/format with the data specified on Test Item (example), and overrides the |name argument with the provided caption.


 * Another article : Uses the wrapper template to generate a formatted, captioned link.

ru:Справка:UsingData