From MHWiki
Revision as of 12:17, 25 October 2011 by Ericb (talk | contribs) (Graduate to main template namespace from User:Ericb/Use)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Since this wiki lacks Extension:ParserFunctions such as {{#if:test|if text|if empty}}, it is desirable to provide an alternate syntax for conditional expansion (choosing one of two strings depending on whether the test string is empty, or choosing one of two strings depending on whether the test string matches a target string). This template is the workhorse behind conditional templates, and exploits some characteristics of named parameters - namely, if a parameter is named more than once, then the last use of that name is valid; and the calling page can use parameter expansions to control which named parameters this template will see.

This macro understands up to two named parameters, and ignores all others. If the named parameter "indir" is given, then its value is an indirection that gives the other named parameter whose value will be used as the overall expansion. Otherwise, the value of the named parameter "use" will be the overall expansion. Examples:

{{use|use=hello}} gives "hello"
{{use|use=first|use=second}} gives "second"
{{use|indir=name|name=hello|use=world}} gives "hello"