Help:Templatefile format – parameter named args

From semantic-mediawiki.org
< Help:Templatefile format
Templatefile formatHelp:Templatefile format – parameter named args
Parameter named args
This help page explains the usage of named arguments when using a template for the templatefile format to display the output of the query.
Keywords

This help page explains the usage of named arguments when using templates for the result format "templatefile"Outputs results in arbitrary file formats defined via templates. to display the output of your queries. Since Semantic MediaWiki 3.2.0Released on 7 September 2020 and compatible with MW 1.31.0 - 1.35.x. you may also use namedargs as the name of the parameter.1

The default value to this parameter is "no" meaning that the arguments for templates are unnamed arguments (also known as anonymous or numerical arguments). Named arguments can be enabled with "yes".

Named arguments via the named args parameter are used to make the connection between the printout statement and the respective template argument easier to comprehend. They are used for convenience and increased wikitext transparency.

Example[edit]

Syntax
{{#ask:
 [[Has GND::+]]
 |?Has GND=gnd
 |?Foaf:name=name
 |format=templatefile
 |introtemplate=BEACONIntro
 |template=BEACONNamedArgs
 |link=none
 |named args=yes
 |filename=beacon.txt
 |searchlabel=beacon export
}}
Result

beacon export

The templates used to create this example: TableNamedArgsHeader and BEACONNamedArgs.

Notes
  • The argument names are case-sensitive.
  • The "labels" to the printout statements specify the argument names used.
  • To add an argument name to the resulting page you have to use |?=somename. To get a plain output (not linked) additionally use |link=none.
  • The named argument is added to the template like, e.g. {{{somename}}}.
  • To hide the named argument if the result does not have a value for the respective printout statement use, e.g. {{{somename|}}}.
  • To fill the named argument if the result does not have a value for the respective printout statement use, e.g. {{{somename|sometext}}}.

Tabular output[edit]

In comparison the tabular output using the result format "table"Outputs the results in a table (default for queries with printout statements). is created like this:

Syntax
{{#ask:
 [[Has GND::+]]
 |?Has GND=GND
 |?Foaf:name=Name
 |format=table
 |link=none
}}
Result
 GNDName
John Doe123456789John Doe
Max Mustermann987654321Max Mustermann

See also[edit]

References

  1. ^  Semantic MediaWiki: GitHub pull request gh:smw:4664