Template:Hif

From Sarkarverse
Jump to navigation Jump to search
Documentation icon Template documentation[view] [edit] [history] [purge]

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:

  1. 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