Help:Parser functions: Difference between revisions
m (Text replacement - "Category:Help" to "Category:HelpCategory:Help under review") Tag: Reverted |
m (Text replacement - "Category:HelpCategory:Help under review" to "Category:Help") Tag: Manual revert |
||
Line 20: | Line 20: | ||
== Navbox == | == Navbox == | ||
{{Saintapedia}} | {{Saintapedia}} | ||
[[Category:Help | [[Category:Help]] |
Revision as of 23:11, 7 October 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 17:26:45{{#timel: Y F d H:i:s}}
: 2025 January 23 12:26:45
{{#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?