Help:Argument declaration in templates

From semantic-mediawiki.org
(Redirected from Help:Argument declaration in templates)
Help:Argument declaration in templatesArgument declaration in templates/zh-hans
Argument declaration in templates
Argument declaration in templates
Further Information
Provided by: Semantic MediaWiki
Minimum version: 1.4.0
Maximum version: still supported
Function: yes
Tag: no
Name: #declare
Table of Contents

The parser function #declare allows to "declare" template parameters. In was introduced with Semantic MediaWiki 1.4.0Released on 21 November 2008 and compatible with MW 1.13.x - 1.16.x..

So if you are e.g. using the template "Server", you would write:

{{Server
 |Name=Sulcorebutia
 |ID=9907
 |IP=116.203.61.64
 |State=active
}}

Then in the template, one could have used [[Has name::{{{Name}}}]] in order to annotate the server with its ID, IP-address and state, thus making the already complicated template syntax even more complex.

Now, instead of making those annotations, you just keep the templates as they are, and add a declare block in them, like this:

{{#declare:
 Has name=Name
 |Has ID=ID
 |Has IP=IP
 |Has state=State
}}

The left hand side of = is the property, the right hand side the template parameter name that is used to fill that property.

The actual idea is to allow to declare template parameters just as in programming languages that declare parameters in function declarations. This should allow, in the long run, for much better handling of templates, both from a content quality side as well as from a user interface side. For now, it allows for simpler template code.

Example[edit]

See also the example on <sandbox.semantic-mediawiki.org>.

See also[edit]