MediaWiki
Evaluate math expression: {{#expr: expression }}
Comments: <!-- Comment -->
Transclude another page: {{ Page name | optional parameter }}
MediaWiki supports a number of magic words, including:
{{PAGENAME}}
{{FULLPAGENAME}}
(includes the namespace){{PAGENAMEE}}
(URL-encoded page name){{__NOTOC__}}
(hides the Table of Contents){{!}}
(escaped pipe character)- various date/time functions
Escape wiki markup: <nowiki> **this** _formatting_ [[won't be processed]]</nowiki>
(further formatting help)
Define a variable
{{#vardefine: variable-name | variable-value }}
Use a variable
{{#var: variable-name }}
Use a variable, providing a default
{{#var: variable-name | default }}
{{#arraymap: input | delimiter | variable name | code | output delimiter | ending conjunction }}
To remove commas between items, use \s
(space) as a delimiter.
You can process items via template using {{#arraymaptemplate: input | template | delimiter | output delimiter }}
.
Whitespace, including newlines, tabs, and spaces, is stripped from the beginning and end of all the parameters of these parser functions. Workarounds available.
For most of these, negative parameter values count from the right end.
Other available functions: len
, pos
, rpos
, sub
Replace within a string
{{#replace: input | search | replace}}
Split a string into pieces and return one or more of them.
{{#explode:string|delimiter|starting index|quantity of pieces}}
{{#explode:And if you tolerate this| |2}}
returnsyou
{{#explode:String/Functions/Code|/|-1}}
returnsCode
{{#explode:Split%By%Percentage%Signs|%|2}}
returnsPercentage
{{#explode:And if you tolerate this| |2|3}}
returnsyou tolerate this
Get pieces of a page title
{{#titleparts: pagename | number of segments to return | index of first segment to return }}
{{#titleparts: Psalm 1/1/Arguments | 2 | 0 }}
-> Psalm 1/1
Tests whether string is empty. Reference
{{#if: test string | return if not empty | return if empty }}
Tests whether an expression is truthy or falsy. Reference
{{#ifexpr: expression | return if truthy | return if falsy }}
Also available: #ifeq
(if strings are equal), #iferror
, #ifexist
(if page exists), #switch
{{{Triple curly braces}}} are template parameters or form definition tags.
{{Double curly braces}} are a magic word, a parser function, or a template.
[[Double square brackets]] are a link to an internal page. To change the link text, write [[page name|link text]]
.
[Single square brackets] are a link to an external page. To change the link text, write [URL link text]
.
Detailed reference, with examples
{|
Table start
|+
Table caption (optional, only before first row)
|-
Row (the first one is optional)
!
Header cell. Optional. Consecutive table header cells may be added on same line separated by double marks (!!
) or start on new lines, each with its own single mark (!
).
|
Cell. Consecutive table data cells may be added on same line separated by double marks (||
) or start on new lines, each with its own single mark (|
).
|}
Table end
Ask queries the wiki database and returns a table:
{{#ask:
[[Category:City]]
[[Located in::Germany]]
|?Population
|?Area#km² = Size in km²
|limit=10
}}
Show gets a single property value from a single page:
{{#show: Demo:Berlin |?Population |default=0}}
Other available parameters: format
, limit
, offset
, sort
, order
, headers
, mainlabel
, index
, link
, default
, intro
, outro
, searchlabel
, format-specific parameters
Replace {{#vardefine}}
with {{#vardefineecho}}
, which prints the value in the place it's defined