Help:Parser functions: Difference between revisions
m (Text replacement - "Category:HelpCategory:Help under review" to "Category:Help") Tag: Manual revert |
m (Text replacement - "Saintapedia" to "USApedia") |
||
Line 19: | Line 19: | ||
== Navbox == | == Navbox == | ||
{{ | {{USApedia}} | ||
[[Category:Help]] | [[Category:Help]] |
Latest revision as of 23:06, 14 November 2024
|
Parser functions (a type of magic word, along with behavior switches and variables) are features of wikitext that enable various instructions to be given to the MediaWiki software to produce variable output, as is often required in templates.
Basic parser functions are detailed at Mediawikiwiki:Help:Magic words#Parser functions. Additional parser functions are added by the ParserFunctions extension, and are detailed at Mediawikiwiki:Help:Extension:ParserFunctions.
Examples
{{#time: F j, Y}}
will show the current date: January 23, 2025. Other common formats for displaying a date include:
{{#time: n/j/y}}
: 1/23/25,{{#time: m/d/Y}}
: 01/23/2025 (with zero padding added, if necessary, to make the month and day each 2 digits long, and a 4-digit year), and{{#time: Y-m-d}}
: 2025-01-23.{{#time: Y F d H:i:s}}
: 2025 January 23 13:10:50{{#timel: Y F d H:i:s}}
: 2025 January 23 08:10:50
{{#ifexpr: 1 > 0 | yes | no }}
can compare values: yes
{{#ifeq: {{#time: D}} | Fri | TGIF!}}
will display a message only on Fridays:
{{#switch: {{#time: D}} | Fri=TGIF! | Sat=Weekend | Sun=Weekend | #default=Where's my coffee?}}
will display a different message on different days: Where's my coffee?