Changes
→Formatting: added new URLENCODE feature
{{h:h|editor toc}}
A "'''colon function'''" is a [[Help:Template#Predefined_templates|predefined template]] with at least one unnamed parameter, separated from the function name by a colon "''':'''" (unlike ordinary templates using "'''|'''"). Thus the syntax is:
:<nowiki>{{</nowiki> ''function name'' : ''parameter value''<nowiki> }}</nowiki>
The function name is not case-sensitive. Further parameters (if any, depending on the function) are separated by "'''|'''".
==Formatting==
===LC===
Makes a text lowercase.
<nowiki>{{lc:AbCdEf}}</nowiki> gives {{lc:AbCdEf}}.<br />
<nowiki>{{lc:Ä Β Ç}}</nowiki> gives {{lc:Ä Β Ç}}, expected ä β ç.
===UC===
Makes a text uppercase.
<nowiki>{{uc:AbCdEf}}</nowiki> gives {{uc:AbCdEf}}.<br />
<nowiki>{{uc:ä β ß}}</nowiki> gives {{uc:ä β ß}}, expected: Ä Β SS. Don't expect too much.
===LCFIRST===
Makes the first character lowercase: <nowiki>{{lcfirst:Ab Cd}}</nowiki> gives {{lcfirst:Ab Cd}}.
===UCFIRST===
Makes the first character uppercase: <nowiki>{{ucfirst:aB cD}}</nowiki> gives {{ucfirst:aB cD}}.
===URLENCODE===
Converts the text into URL friendly format by replacing spaces with "+": <nowiki>{{urlencode:hello world}}</nowiki> gives {{urlencode:hello world}}
==NS==
Gives the namespace name for a given [[Help:Namespace|namespace]] number or name:
<code><nowiki>{{ns:4}}</nowiki></code> gives {{ns:4}}.<br />
<code><nowiki>{{ns:{{ns:12}}_talk}}</nowiki></code> gives {{ns:{{ns:12}}_talk}}.<br />
<code><nowiki>{{ns:project}}</nowiki></code> gives {{ns:project}}.
However <code><nowiki>{{ns:{{SITENAME}}}}</nowiki></code> for <code><nowiki>{{SITENAME}}</nowiki></code>={{SITENAME}} doesn't work, on Meta it has the same effect as <code><nowiki>{{Meta}}</nowiki><code>, calling an existing [[m:Template:Meta|Template:Meta]].
Similarly <code><nowiki>{{ns:{{ns:8}} talk}}</nowiki></code> fails without underscore: {{ns:{{ns:8}} talk}}. See [[Help:Variable]] for more canonical names like "'''<tt>project</tt>'''" and "'''<tt>talk</tt>'''".
=== NS:1 ===
<code><nowiki>{{ns:{{ns:0}}_talk}}</nowiki></code> fails: {{ns:{{ns:0}} talk}}. The canonical name for the talk namespace of articles is "'''<tt>talk</tt>'''" and not "'''<tt>_talk</tt>'''". But the following constructs work:
<code><nowiki>{{ns:01}}</nowiki></code> gives {{ns:01}},
<code><nowiki>{{ns:+1}}</nowiki></code> gives {{ns:+1}},
<code><nowiki>{{ns:TALK}}</nowiki></code> gives {{ns:TALK}}, and
<code><nowiki>{{ns:{{ns:1}}}}</nowiki></code> gives also {{ns:{{ns:1}}}}. Space sensitive, but not case sensitive.
=== NS:0 ===
<code><nowiki>'''#{{ns:0}}#'''</nowiki></code> gives '''#{{ns:0}}#''', an empty string. This is often handy, less vulnerable than a template '''void''' or similar,
and less cryptic than [[Help:magic words|magic words]] like <tt><nowiki>__END__</nowiki></tt>.
In constructs like <code><nowiki>{{ {{#if: {{{T|}}} | {{{T}}} | ns:0}} }}</nowiki></code>, where parameter '''T''' is
normally the name of a template to be evaluated, but can be undefined or empty, <code><nowiki>{{ns:0}}</nowiki></code>
is then a clean empty string. Without it <code><nowiki>{{}}</nowiki></code> would result in {{}}.
Please note that <code><nowiki>{{ns:{{ns:0}}}}</nowiki></code> fails: {{ns:{{ns:0}}}}. NS cannot handle an empty <code><nowiki>{{ns:0}}</nowiki></code> argument.
==== {{ns:0}} ====
An empty section title like above is obtained using, in this case, <code><nowiki>==== {{ns:0}} ====</nowiki></code>. This is dubious, but arguably better than using the same trick to get invisble section headers twice on a page. At least <tt><nowiki>/* {{ns:0}} */</nowiki></tt> 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 <code><nowiki>__NOTOC__</nowiki></code> 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:
# <code><nowiki>=== __NOTOC__ ===</nowiki></code>
# <code><nowiki>=== ===</nowiki></code>
# <code><nowiki>=== &nbsp; ===</nowiki></code>
# <code><nowiki>=== &#160; ===</nowiki></code>
== #language: ==
<code>{{#language: ''code''}}</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 [http://www.iana.org/assignments/language-subtag-registry IANA registry].
:{{evaldemo|#language:da}}
:{{evaldemo|#language:fo}}
:{{evaldemo|#language:zh}}
:{{evaldemo|#language:zh-min-nan}}
:{{evaldemo|#language:ang}}
:{{evaldemo|#language:tlh}} (missing, incomplete list)
:{{evaldemo|#language:frr}} (missing, introduced 2006)
:{{evaldemo|#language:mw}} (no language code as of 2006)
This function will replace {{tim|n local}} and some of the [[Special:Prefixindex/Template:Lang name -]] templates.
For actually supported alpha2 and alpha3 codes see {{tim|sttnw}}, 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 {{tim|tc}}, <nowiki>{{uc:{{tc}}}}</nowiki> gives {{uc:in}}.
*using {{tim|x3}}, <nowiki>{{#expr:{{x3|1}}/3}}</nowiki> gives {{#expr:111/3}}
===Substitution===
:''See also: '''[[Help:Substitution]]'''.''
Applying "subst:" to a colon function works:
<nowiki>{{subst:LC:AbC}}</nowiki> gives abc.
Note that unless a technique like [[Help:Substitution#Optional substitution|optional recursive substitution]]
is used, substituting a template which uses a colon function does not replace that colon function with its result.
===See also===
*[[Help:Magic words]]
*[[ParserFunctions]]
*{{tim|colon function}}
*{{tim|wikivar}}
{{h:f|langs=|enname=colon function}}
A "'''colon function'''" is a [[Help:Template#Predefined_templates|predefined template]] with at least one unnamed parameter, separated from the function name by a colon "''':'''" (unlike ordinary templates using "'''|'''"). Thus the syntax is:
:<nowiki>{{</nowiki> ''function name'' : ''parameter value''<nowiki> }}</nowiki>
The function name is not case-sensitive. Further parameters (if any, depending on the function) are separated by "'''|'''".
==Formatting==
===LC===
Makes a text lowercase.
<nowiki>{{lc:AbCdEf}}</nowiki> gives {{lc:AbCdEf}}.<br />
<nowiki>{{lc:Ä Β Ç}}</nowiki> gives {{lc:Ä Β Ç}}, expected ä β ç.
===UC===
Makes a text uppercase.
<nowiki>{{uc:AbCdEf}}</nowiki> gives {{uc:AbCdEf}}.<br />
<nowiki>{{uc:ä β ß}}</nowiki> gives {{uc:ä β ß}}, expected: Ä Β SS. Don't expect too much.
===LCFIRST===
Makes the first character lowercase: <nowiki>{{lcfirst:Ab Cd}}</nowiki> gives {{lcfirst:Ab Cd}}.
===UCFIRST===
Makes the first character uppercase: <nowiki>{{ucfirst:aB cD}}</nowiki> gives {{ucfirst:aB cD}}.
===URLENCODE===
Converts the text into URL friendly format by replacing spaces with "+": <nowiki>{{urlencode:hello world}}</nowiki> gives {{urlencode:hello world}}
==NS==
Gives the namespace name for a given [[Help:Namespace|namespace]] number or name:
<code><nowiki>{{ns:4}}</nowiki></code> gives {{ns:4}}.<br />
<code><nowiki>{{ns:{{ns:12}}_talk}}</nowiki></code> gives {{ns:{{ns:12}}_talk}}.<br />
<code><nowiki>{{ns:project}}</nowiki></code> gives {{ns:project}}.
However <code><nowiki>{{ns:{{SITENAME}}}}</nowiki></code> for <code><nowiki>{{SITENAME}}</nowiki></code>={{SITENAME}} doesn't work, on Meta it has the same effect as <code><nowiki>{{Meta}}</nowiki><code>, calling an existing [[m:Template:Meta|Template:Meta]].
Similarly <code><nowiki>{{ns:{{ns:8}} talk}}</nowiki></code> fails without underscore: {{ns:{{ns:8}} talk}}. See [[Help:Variable]] for more canonical names like "'''<tt>project</tt>'''" and "'''<tt>talk</tt>'''".
=== NS:1 ===
<code><nowiki>{{ns:{{ns:0}}_talk}}</nowiki></code> fails: {{ns:{{ns:0}} talk}}. The canonical name for the talk namespace of articles is "'''<tt>talk</tt>'''" and not "'''<tt>_talk</tt>'''". But the following constructs work:
<code><nowiki>{{ns:01}}</nowiki></code> gives {{ns:01}},
<code><nowiki>{{ns:+1}}</nowiki></code> gives {{ns:+1}},
<code><nowiki>{{ns:TALK}}</nowiki></code> gives {{ns:TALK}}, and
<code><nowiki>{{ns:{{ns:1}}}}</nowiki></code> gives also {{ns:{{ns:1}}}}. Space sensitive, but not case sensitive.
=== NS:0 ===
<code><nowiki>'''#{{ns:0}}#'''</nowiki></code> gives '''#{{ns:0}}#''', an empty string. This is often handy, less vulnerable than a template '''void''' or similar,
and less cryptic than [[Help:magic words|magic words]] like <tt><nowiki>__END__</nowiki></tt>.
In constructs like <code><nowiki>{{ {{#if: {{{T|}}} | {{{T}}} | ns:0}} }}</nowiki></code>, where parameter '''T''' is
normally the name of a template to be evaluated, but can be undefined or empty, <code><nowiki>{{ns:0}}</nowiki></code>
is then a clean empty string. Without it <code><nowiki>{{}}</nowiki></code> would result in {{}}.
Please note that <code><nowiki>{{ns:{{ns:0}}}}</nowiki></code> fails: {{ns:{{ns:0}}}}. NS cannot handle an empty <code><nowiki>{{ns:0}}</nowiki></code> argument.
==== {{ns:0}} ====
An empty section title like above is obtained using, in this case, <code><nowiki>==== {{ns:0}} ====</nowiki></code>. This is dubious, but arguably better than using the same trick to get invisble section headers twice on a page. At least <tt><nowiki>/* {{ns:0}} */</nowiki></tt> 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 <code><nowiki>__NOTOC__</nowiki></code> 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:
# <code><nowiki>=== __NOTOC__ ===</nowiki></code>
# <code><nowiki>=== ===</nowiki></code>
# <code><nowiki>=== &nbsp; ===</nowiki></code>
# <code><nowiki>=== &#160; ===</nowiki></code>
== #language: ==
<code>{{#language: ''code''}}</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 [http://www.iana.org/assignments/language-subtag-registry IANA registry].
:{{evaldemo|#language:da}}
:{{evaldemo|#language:fo}}
:{{evaldemo|#language:zh}}
:{{evaldemo|#language:zh-min-nan}}
:{{evaldemo|#language:ang}}
:{{evaldemo|#language:tlh}} (missing, incomplete list)
:{{evaldemo|#language:frr}} (missing, introduced 2006)
:{{evaldemo|#language:mw}} (no language code as of 2006)
This function will replace {{tim|n local}} and some of the [[Special:Prefixindex/Template:Lang name -]] templates.
For actually supported alpha2 and alpha3 codes see {{tim|sttnw}}, 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 {{tim|tc}}, <nowiki>{{uc:{{tc}}}}</nowiki> gives {{uc:in}}.
*using {{tim|x3}}, <nowiki>{{#expr:{{x3|1}}/3}}</nowiki> gives {{#expr:111/3}}
===Substitution===
:''See also: '''[[Help:Substitution]]'''.''
Applying "subst:" to a colon function works:
<nowiki>{{subst:LC:AbC}}</nowiki> gives abc.
Note that unless a technique like [[Help:Substitution#Optional substitution|optional recursive substitution]]
is used, substituting a template which uses a colon function does not replace that colon function with its result.
===See also===
*[[Help:Magic words]]
*[[ParserFunctions]]
*{{tim|colon function}}
*{{tim|wikivar}}
{{h:f|langs=|enname=colon function}}