Template:Hif: Difference between revisions
m (1 revision) |
(No difference)
|
Latest revision as of 12:01, 6 November 2013
Usage
This template detects if a character string begins with a #.
By default, the template returns a "1" if it starts with a hash sign, or a "0" otherwise. By inputing the "then" and "else" parameters, you can choose to output a string instead. These returns can then be used in {{switch}} or other templates, or directly in what you are using, to generate the desired effect.
Chiefly, this template is designed to fix a certain error that occurs when using HTML Colour Codes (e.g. "#345342"), which is, quite simply, that in certain cases, WikiMarkup takes the "#xxxxxx" to mean:
- xxxxxx
which is obviously not desired. This template can be used to catch Colour Codes that have been entered with the "#" character, then to avoid an error by replacing with xxxxxx (in most cases an HTML Colour Code does not actually require a #).
Examples
Input | Returns |
---|---|
{{hif|test=colourcode}} |
0 |
Input | Returns |
---|---|
{{hif|test=#colourcode}} |
1 |
Input | Returns |
---|---|
{{hif|test=colourcode|then=foo|else=bar}} |
bar |
Input | Returns |
---|---|
{{hif|test=#colourcode|then=foo|else=bar}} |
foo |
See also
The above documentation is transcluded from Template:Hif/doc. (edit | history) Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages. Please add categories to the /doc subpage. Subpages of this template. |