Template talk:Sif
From Wikipedia, the free encyclopedia
This template uses a lucky quirk of WikiMarkup to detect if a parameter contains a space character.
It returns either 1 or 0 accordingly, or can optionally return a string of your choosing. These returns can then be used in {{switch}} or other templates, or directly in what you are using, to generate the desired effect.
Detecting spaces can often be useful when parameters are going to become external links, or when singular words are required, possibly even to stop people from entering sentences or being overly descriptive or splitting up terms (e.g. Metasyntactic, not Meta syntactic) in a list of singular word terms, for instance, to replace with a default value (possibly). Detecting a space has many uses.
The template could also be described as a detector of multiple word parameters.
[edit] Examples
Code | Returns |
---|---|
{{Sif|foobar}} |
1 |
Code | Returns |
---|---|
{{Sif|foo bar}} |
1 |
Code | Returns |
---|---|
{{Sif|barbaz|then=space|else=nospace}} |
space |
Code | Returns |
---|---|
{{Sif|bar baz|then=space|else=nospace}} |
space |
See also m:Template:csp (talk, backlinks, edit), which is based on this template.