Template talk:Hif

From Wikipedia, the free encyclopedia

This template is based on {{#ifexist}} ignoring any sections and looking only at if the page exists.

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. The template has undefined behavior if any pages starting with "Template:Hif" exist (including Wikipedia:subpages).

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 #).

[edit] 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