New Immissions/Updates:
boundless - educate - edutalab - empatico - es-ebooks - es16 - fr16 - fsfiles - hesperian - solidaria - wikipediaforschools
- wikipediaforschoolses - wikipediaforschoolsfr - wikipediaforschoolspt - worldmap -

See also: Liber Liber - Libro Parlato - Liber Musica  - Manuzio -  Liber Liber ISO Files - Alphabetical Order - Multivolume ZIP Complete Archive - PDF Files - OGG Music Files -

PROJECT GUTENBERG HTML: Volume I - Volume II - Volume III - Volume IV - Volume V - Volume VI - Volume VII - Volume VIII - Volume IX

Ascolta ""Volevo solo fare un audiolibro"" su Spreaker.
CLASSICISTRANIERI HOME PAGE - YOUTUBE CHANNEL
Privacy Policy Cookie Policy Terms and Conditions
Help:Parser function - Wikipedia, the free encyclopedia

Help:Parser function

From Wikipedia, the free encyclopedia

This is a copy of the master help page at Meta. Do not edit this copy.
Edits will be lost in the next update from the master page. See below for more information.


Editing
Start new pages
Page name

Referencing
Links
Piped links
Interwiki linking
Footnotes (References)

Formatting
Wikitext
Lists & Tables
Image & file uploads
Formulae

Organising
Sections
Categories
Redirects (forward)
Namespaces
Moving a page
Page size

Fixing mistakes
Reverting edits
Show preview

Saving effort
Editing shortcuts
Edit toolbar
Magic words
Templates
Variables
Calculation

Communicating
Edit summary
Talk page
Edit conflict
Minor edit

Other
Characters
Sandbox


A "parser function" is a template-like construct which returns a value based on at least one unnamed parameter, separated from the function name by a colon ":" (unlike ordinary templates using "|"). Thus the syntax is:

{{functionname: argument 1 | argument 2 | argument 3...}}

or

{{#functionname: argument 1 | argument 2 | argument 3...}}

The function name is not case-sensitive. Further parameters (if any, depending on the function) are separated by "|".

Core parser functions are built into MediaWiki. For backwards compatibility, they typically have no leading hash character. Extension parser functions, such as those provided by the ParserFunctions extension, typically have a leading hash character "#" to prevent collision with namespaces and interwiki prefixes.

MediaWiki's core parser functions are listed below.

Contents

Formatting

LC

Makes a text lowercase.

{{lc:AbCdEf}} gives abcdef.
{{lc:Ä Β Ç}} gives ä β ç, expected ä β ç.

UC

Makes a text uppercase.

{{uc:AbCdEf}} gives ABCDEF.
{{uc:ä β ß}} gives Ä Β ß, expected: Ä Β SS. Don't expect too much.

LCFIRST

Makes the first character lowercase: {{lcfirst:Ab Cd}} gives ab Cd.

UCFIRST

Makes the first character uppercase: {{ucfirst:aB cD}} gives AB cD.

URLENCODE

Converts the text into URL friendly format by replacing spaces with "+" and other url formatting characters with their escaped equivalents: {{urlencode:hello world ?&=#/:}} gives hello+world+%3F%26%3D%23%2F%3A.

NS

Gives the namespace name for a given namespace number or name:

{{ns:4}} gives Wikipedia.
{{ns:{{ns:12}}_talk}} gives Help_talk.
{{ns:project}} gives Wikipedia.

However {{ns:{{SITENAME}}}} for {{SITENAME}}=Wikipedia doesn't work, on Meta it has the same effect as {{Meta}}, calling an existing Template:Meta.

Similarly {{ns:{{ns:8}} talk}} fails without underscore: MediaWiki_talk. See Help:Variable for more canonical names like "project" and "talk".

NS:1

{{ns:{{ns:0}}_talk}} fails: Talk. The canonical name for the talk namespace of articles is "talk" and not "_talk". But the following constructs work:

{{ns:01}} gives Talk, {{ns:+1}} gives Talk, {{ns:TALK}} gives Talk, and {{ns:{{ns:1}}}} gives also Talk. Space sensitive, but not case sensitive.

NS:0

'''#{{ns:0}}#''' gives ##, an empty string. This is often handy, less vulnerable than a template void or similar, and less cryptic than magic words like __END__.

In constructs like {{ {{#if: {{{T|}}} | {{{T}}} | ns:0}} }}, where parameter T is normally the name of a template to be evaluated, but can be undefined or empty, {{ns:0}} is then a clean empty string. Without it {{}} would result in {{}}.

Please note that {{ns:{{ns:0}}}} fails: Template:Ns:. NS cannot handle an empty {{ns:0}} argument.

An empty section title like above is obtained using, in this case, ==== {{ns:0}} ====. This is dubious, but arguably better than using the same trick to get invisble section headers twice on a page. At least /* {{ns:0}} */ makes sense in the edit history, if there's only one section using this particular trick.

As shown in the table of contents this and similar tricks result in non-functional links. In conjunction with __NOTOC__ it's less harmful, and maybe useful to get edit links for invisible sections with categories and interlanguage links. Other possibilities for different invisible section headers:

  1. === __NOTOC__ ===
  2. === ===
  3. ===   ===
  4. ===   ===

#language:

{{#language: code}} gives the language name of selected RFC 3066 language codes, otherwise it returns the input value as is. For a complete list see the IANA registry.

{{ #language:da }} gives Dansk
{{ #language:fo }} gives Føroyskt
{{ #language:zh }} gives 中文
{{ #language:zh-min-nan }} gives Bân-lâm-gú
{{ #language:ang }} gives Anglo Saxon
{{ #language:tlh }} gives tlh (missing, incomplete list)
{{ #language:frr }} gives frr (missing, introduced 2006)
{{ #language:mw }} gives mw (no language code as of 2006)

This function will replace m:Template:n local (talk, backlinks, edit) and some of the Special:Prefixindex/Template:Lang name - templates. For actually supported alpha2 and alpha3 codes see m:Template:sttnw (talk, backlinks, edit), the 27*26*26 template calls may take some time.

General features

The parameter value can be an expression involving (possibly multilevel): concatenation, applying a template or parser function, or using a variable.

Examples:

Substitution

See also: Help:Substitution.

Applying "subst:" to a parser function works:

{{subst:LC:AbC}} gives abc.

Note that unless a technique like optional recursive substitution is used, substituting a template which uses a parser function does not replace that parser function with its result.

Terminology and history

Core parser functions were originally collectively unnamed in the MediaWiki codebase, although they were informally referred to simply as "functions" by developers. At some time around February 2006, editors of this documentation labelled them "colon functions", an unusual term which was unknown to the developers and the majority of users. In April 2006, the ParserFunctions extension was introduced, along with a new extension interface allowing efficient addition of arbitrary numbers of these entities, now labelled "parser functions". The syntax for the new parser functions was modelled on that of the old core parser functions, the main difference being the addition of the leading hash "#".

In July 2006, the parser function interface was extended to allow old-style hashless functions, and the old core parser functions were converted from using special-case code to the new parser function interface. They were moved to a CoreParserFunctions module. Thus today, there is no difference at all in syntax or functionality between core parser functions and extension parser functions, besides the leading hash convention.

Despite this, some users are in the habit of reserving the term "parser function" for members of the ParserFunctions extension. This is confusing and inaccurate -- any extension may define a parser function. The parser function interface has diverse applications. Perhaps it was confusing to call the extension ParserFunctions in the first place, but it was imagined as a fairly general repository of parser functions useful to Wikimedia.


See also


edit

Wikipedia-specific help

This page in the handbook is not yet ready. Some colon functions are at the moment only enumerated in the overview page Help:Magic words. Check out the latest state of m:Help:Parser function on Meta. Maybe edit it there and/or copy it to Wikipedia as explained below.
ParserFunctions is one set of parser functions, in an optional extension installed among others on Wikipedia. They have their own documentation.

This page is a copy of the master help page at Meta (for general help information all Wikimedia projects can use), with two Wikipedia-specific templates inserted. To update the main text, edit the master help page for all projects at m:Help:Parser function. For Wikipedia-specific issues, use Template:Ph:Parser function (the extra text at the bottom of this page) or Template:Phh:Parser function for a Wikipedia-specific lead (text appears at the top of this page). You are welcome to copy the exact wikitext from the master page at Meta and paste it into this page at any time. To view this page in other languages see the master page at Meta.

Static Wikipedia (no images)

aa - ab - af - ak - als - am - an - ang - ar - arc - as - ast - av - ay - az - ba - bar - bat_smg - bcl - be - be_x_old - bg - bh - bi - bm - bn - bo - bpy - br - bs - bug - bxr - ca - cbk_zam - cdo - ce - ceb - ch - cho - chr - chy - co - cr - crh - cs - csb - cu - cv - cy - da - de - diq - dsb - dv - dz - ee - el - eml - en - eo - es - et - eu - ext - fa - ff - fi - fiu_vro - fj - fo - fr - frp - fur - fy - ga - gan - gd - gl - glk - gn - got - gu - gv - ha - hak - haw - he - hi - hif - ho - hr - hsb - ht - hu - hy - hz - ia - id - ie - ig - ii - ik - ilo - io - is - it - iu - ja - jbo - jv - ka - kaa - kab - kg - ki - kj - kk - kl - km - kn - ko - kr - ks - ksh - ku - kv - kw - ky - la - lad - lb - lbe - lg - li - lij - lmo - ln - lo - lt - lv - map_bms - mdf - mg - mh - mi - mk - ml - mn - mo - mr - mt - mus - my - myv - mzn - na - nah - nap - nds - nds_nl - ne - new - ng - nl - nn - no - nov - nrm - nv - ny - oc - om - or - os - pa - pag - pam - pap - pdc - pi - pih - pl - pms - ps - pt - qu - quality - rm - rmy - rn - ro - roa_rup - roa_tara - ru - rw - sa - sah - sc - scn - sco - sd - se - sg - sh - si - simple - sk - sl - sm - sn - so - sr - srn - ss - st - stq - su - sv - sw - szl - ta - te - tet - tg - th - ti - tk - tl - tlh - tn - to - tpi - tr - ts - tt - tum - tw - ty - udm - ug - uk - ur - uz - ve - vec - vi - vls - vo - wa - war - wo - wuu - xal - xh - yi - yo - za - zea - zh - zh_classical - zh_min_nan - zh_yue - zu -

Static Wikipedia 2007 (no images)

aa - ab - af - ak - als - am - an - ang - ar - arc - as - ast - av - ay - az - ba - bar - bat_smg - bcl - be - be_x_old - bg - bh - bi - bm - bn - bo - bpy - br - bs - bug - bxr - ca - cbk_zam - cdo - ce - ceb - ch - cho - chr - chy - co - cr - crh - cs - csb - cu - cv - cy - da - de - diq - dsb - dv - dz - ee - el - eml - en - eo - es - et - eu - ext - fa - ff - fi - fiu_vro - fj - fo - fr - frp - fur - fy - ga - gan - gd - gl - glk - gn - got - gu - gv - ha - hak - haw - he - hi - hif - ho - hr - hsb - ht - hu - hy - hz - ia - id - ie - ig - ii - ik - ilo - io - is - it - iu - ja - jbo - jv - ka - kaa - kab - kg - ki - kj - kk - kl - km - kn - ko - kr - ks - ksh - ku - kv - kw - ky - la - lad - lb - lbe - lg - li - lij - lmo - ln - lo - lt - lv - map_bms - mdf - mg - mh - mi - mk - ml - mn - mo - mr - mt - mus - my - myv - mzn - na - nah - nap - nds - nds_nl - ne - new - ng - nl - nn - no - nov - nrm - nv - ny - oc - om - or - os - pa - pag - pam - pap - pdc - pi - pih - pl - pms - ps - pt - qu - quality - rm - rmy - rn - ro - roa_rup - roa_tara - ru - rw - sa - sah - sc - scn - sco - sd - se - sg - sh - si - simple - sk - sl - sm - sn - so - sr - srn - ss - st - stq - su - sv - sw - szl - ta - te - tet - tg - th - ti - tk - tl - tlh - tn - to - tpi - tr - ts - tt - tum - tw - ty - udm - ug - uk - ur - uz - ve - vec - vi - vls - vo - wa - war - wo - wuu - xal - xh - yi - yo - za - zea - zh - zh_classical - zh_min_nan - zh_yue - zu -

Static Wikipedia 2006 (no images)

aa - ab - af - ak - als - am - an - ang - ar - arc - as - ast - av - ay - az - ba - bar - bat_smg - bcl - be - be_x_old - bg - bh - bi - bm - bn - bo - bpy - br - bs - bug - bxr - ca - cbk_zam - cdo - ce - ceb - ch - cho - chr - chy - co - cr - crh - cs - csb - cu - cv - cy - da - de - diq - dsb - dv - dz - ee - el - eml - eo - es - et - eu - ext - fa - ff - fi - fiu_vro - fj - fo - fr - frp - fur - fy - ga - gan - gd - gl - glk - gn - got - gu - gv - ha - hak - haw - he - hi - hif - ho - hr - hsb - ht - hu - hy - hz - ia - id - ie - ig - ii - ik - ilo - io - is - it - iu - ja - jbo - jv - ka - kaa - kab - kg - ki - kj - kk - kl - km - kn - ko - kr - ks - ksh - ku - kv - kw - ky - la - lad - lb - lbe - lg - li - lij - lmo - ln - lo - lt - lv - map_bms - mdf - mg - mh - mi - mk - ml - mn - mo - mr - mt - mus - my - myv - mzn - na - nah - nap - nds - nds_nl - ne - new - ng - nl - nn - no - nov - nrm - nv - ny - oc - om - or - os - pa - pag - pam - pap - pdc - pi - pih - pl - pms - ps - pt - qu - quality - rm - rmy - rn - ro - roa_rup - roa_tara - ru - rw - sa - sah - sc - scn - sco - sd - se - sg - sh - si - simple - sk - sl - sm - sn - so - sr - srn - ss - st - stq - su - sv - sw - szl - ta - te - tet - tg - th - ti - tk - tl - tlh - tn - to - tpi - tr - ts - tt - tum - tw - ty - udm - ug - uk - ur - uz - ve - vec - vi - vls - vo - wa - war - wo - wuu - xal - xh - yi - yo - za - zea - zh - zh_classical - zh_min_nan - zh_yue - zu

Static Wikipedia February 2008 (no images)

aa - ab - af - ak - als - am - an - ang - ar - arc - as - ast - av - ay - az - ba - bar - bat_smg - bcl - be - be_x_old - bg - bh - bi - bm - bn - bo - bpy - br - bs - bug - bxr - ca - cbk_zam - cdo - ce - ceb - ch - cho - chr - chy - co - cr - crh - cs - csb - cu - cv - cy - da - de - diq - dsb - dv - dz - ee - el - eml - en - eo - es - et - eu - ext - fa - ff - fi - fiu_vro - fj - fo - fr - frp - fur - fy - ga - gan - gd - gl - glk - gn - got - gu - gv - ha - hak - haw - he - hi - hif - ho - hr - hsb - ht - hu - hy - hz - ia - id - ie - ig - ii - ik - ilo - io - is - it - iu - ja - jbo - jv - ka - kaa - kab - kg - ki - kj - kk - kl - km - kn - ko - kr - ks - ksh - ku - kv - kw - ky - la - lad - lb - lbe - lg - li - lij - lmo - ln - lo - lt - lv - map_bms - mdf - mg - mh - mi - mk - ml - mn - mo - mr - mt - mus - my - myv - mzn - na - nah - nap - nds - nds_nl - ne - new - ng - nl - nn - no - nov - nrm - nv - ny - oc - om - or - os - pa - pag - pam - pap - pdc - pi - pih - pl - pms - ps - pt - qu - quality - rm - rmy - rn - ro - roa_rup - roa_tara - ru - rw - sa - sah - sc - scn - sco - sd - se - sg - sh - si - simple - sk - sl - sm - sn - so - sr - srn - ss - st - stq - su - sv - sw - szl - ta - te - tet - tg - th - ti - tk - tl - tlh - tn - to - tpi - tr - ts - tt - tum - tw - ty - udm - ug - uk - ur - uz - ve - vec - vi - vls - vo - wa - war - wo - wuu - xal - xh - yi - yo - za - zea - zh - zh_classical - zh_min_nan - zh_yue - zu