Help:Colon function
A "colon function" is a predefined template with at least one unnamed parameter, separated from the function name by a colon ":" (unlike ordinary templates using "|"). Thus the syntax is:
- {{ function name : parameter value }}
The function name is not case-sensitive. Further parameters (if any, depending on the function) are separated by "|".
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 Ä Β SS, 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 "+": {{urlencode:hello world}} gives hello+world
NS
Gives the namespace name for a given namespace number or name:
{{ns:4}}
gives wiki.thepatternofeverything.org.
{{ns:{{ns:12}}_talk}}
gives Help talk.
{{ns:project}}
gives wiki.thepatternofeverything.org.
However {{ns:{{SITENAME}}}}
for {{SITENAME}}
=wiki.thepatternofeverything.org doesn't work, on Meta it has the same effect as {{Meta}}<code>, calling an existing Template:Meta.
Similarly <code>{{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: . 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:
-
=== __NOTOC__ ===
-
=== ===
-
=== ===
-
===   ===
#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.
- Template:Evaldemo
- Template:Evaldemo
- Template:Evaldemo
- Template:Evaldemo
- Template:Evaldemo
- Template:Evaldemo (missing, incomplete list)
- Template:Evaldemo (missing, introduced 2006)
- Template:Evaldemo (no language code as of 2006)
This function will replace Template:N local and some of the Special:Prefixindex/Template:Lang name - templates. For actually supported alpha2 and alpha3 codes see 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, parser function, or colon function, or using a variable.
Examples:
- using Template:Tc, {{uc:{{tc}}}} gives IN.
- using Template:X3, {{#expr:{{x3|1}}/3}} gives {{#expr:111/3}}
Substitution
- See also: Help:Substitution.
Applying "subst:" to a colon function works:
{{subst:LC:AbC}} gives abc.
Note that unless a technique like optional recursive substitution is used, substituting a template which uses a colon function does not replace that colon function with its result.
See also
method a | method b | generates |
---|---|---|
common namespaces [-2 - 15] / used at all MediaWiki projects | ||
{{ns:-2}} | {{ns:Media}} | Media |
{{ns:-1}} | {{ns:Special}} | Special |
{{ns:1}} | {{ns:Talk}} | Talk |
{{ns:2}} | {{ns:User}} | User |
{{ns:3}} | {{ns:User_talk}} | User talk |
{{ns:4}} | {{ns:Project}} | wiki.thepatternofeverything.org |
{{ns:5}} | {{ns:Project_talk}} | wiki.thepatternofeverything.org talk |
{{ns:6}} | {{ns:Image}} | File |
{{ns:7}} | {{ns:Image_talk}} | File talk |
{{ns:8}} | {{ns:MediaWiki}} | MediaWiki |
{{ns:9}} | {{ns:MediaWiki_talk}} | MediaWiki talk |
{{ns:10}} | {{ns:Template}} | Template |
{{ns:11}} | {{ns:Template_talk}} | Template talk |
{{ns:12}} | {{ns:Help}} | Help |
{{ns:13}} | {{ns:Help_talk}} | Help talk |
{{ns:14}} | {{ns:Category}} | Category |
{{ns:15}} | {{ns:Category_talk}} | Category talk |
custom namespace | ||
{{ns:100}} | ||
{{ns:101}} | ||
{{ns:102}} | ||
{{ns:103}} | ||
{{ns:121}} | ||
{{SITENAME}} | wiki.thepatternofeverything.org | |
{{SERVER}} | http://wiki.archetypepattern.org |