User:Ericb/Use

From MHWiki

This page was my playground before creating Template:Use

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}} gives "hello"