Difference between revisions of "Help:Colon function"
(→UC) |
(→General features) |
||
(4 intermediate revisions by the same user not shown) | |||
Line 21: | Line 21: | ||
===LCFIRST=== | ===LCFIRST=== | ||
− | Makes the first character lowercase: <nowiki>{{lcfirst:Ab Cd}}</nowiki> | + | Makes the first character lowercase: <nowiki>{{lcfirst:Ab Cd}}</nowiki>. |
===UCFIRST=== | ===UCFIRST=== | ||
− | Makes the first character uppercase: <nowiki>{{ucfirst:aB cD}}</nowiki> | + | Makes the first character uppercase: <nowiki>{{ucfirst:aB cD}}</nowiki>. |
===URLENCODE=== | ===URLENCODE=== | ||
− | Converts the text into URL friendly format by replacing spaces with "+": <nowiki>{{urlencode:hello world}}</nowiki> | + | Converts the text into URL friendly format by replacing spaces with "+": <nowiki>{{urlencode:hello world}}</nowiki> |
==NS== | ==NS== | ||
Line 36: | Line 36: | ||
<code><nowiki>{{ns:project}}</nowiki></code> gives {{ns:project}}. | <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 | + | 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 Template:Meta. |
=== NS:1 === | === NS:1 === | ||
− | <code><nowiki>{{ns:{{ns:0}}_talk}}</nowiki></code> | + | <code><nowiki>{{ns:{{ns:0}}_talk}}</nowiki></code>. 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:01}}</nowiki></code> gives {{ns:01}}, | ||
Line 50: | Line 50: | ||
=== NS:0 === | === NS:0 === | ||
− | <code><nowiki>'''#{{ns:0}}#'''</nowiki></code> | + | <code><nowiki>'''#{{ns:0}}#'''</nowiki></code>, 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>. | and less cryptic than [[Help:magic words|magic words]] like <tt><nowiki>__END__</nowiki></tt>. | ||
Line 57: | Line 57: | ||
is then a clean empty string. Without it <code><nowiki>{{}}</nowiki></code> would result in {{}}. | 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> | + | Please note that <code><nowiki>{{ns:{{ns:0}}}}</nowiki></code>. NS cannot handle an empty <code><nowiki>{{ns:0}}</nowiki></code> argument. |
− | ==== {{ns:0}} ==== | + | ==== <nowiki>{{ns:0}}</nowiki> ==== |
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. | 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. | ||
Line 71: | Line 71: | ||
== #language: == | == #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]. | <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]. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
===Substitution=== | ===Substitution=== | ||
Line 93: | Line 86: | ||
*[[Help:Magic words]] | *[[Help:Magic words]] | ||
*[[ParserFunctions]] | *[[ParserFunctions]] | ||
− | |||
− | |||
[[Category:Help|Help:Colon_function]] | [[Category:Help|Help:Colon_function]] |
Latest revision as of 09:55, 12 July 2006
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}}.
{{lc:Ä Β Ç}}, expected ä β ç.
UC
Makes a text uppercase.
{{uc:AbCdEf}}.
{{uc:ä β ß}}, expected: Ä Β SS. Don't expect too much.
LCFIRST
Makes the first character lowercase: {{lcfirst:Ab Cd}}.
UCFIRST
Makes the first character uppercase: {{ucfirst:aB cD}}.
URLENCODE
Converts the text into URL friendly format by replacing spaces with "+": {{urlencode: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.
NS:1
<code>{{ns:{{ns:0}}_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}}#'''
, 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}}}}
. NS cannot handle an empty {{ns:0}}
argument.
{{ns:0}}
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.
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.