Template:Ifexpr

With this template #ifexpr can be used in a way such that it does not strip spaces and newlines from the "then" and "else" part.

Usage
Compare:
 * gives ""
 * gives ""
 * gives ""
 * gives ""
 * gives ""
 * gives ""
 * gives ""

Note that, unlike parser functions, templates require writing equals signs in values of unnamed parameters by using double-braces, as. So, to allow "=" (or "<=" or ">=") then use the named parameter 1, as in: 1=>=7.

For full substitution, simply use  or. If the condition contains a parser function, template, or variable, that should be substituted too. Optionally the "then" or "else" part can also be substituted.

Error messages (examples):


 * gives
 * gives, for e3.
 * gives, because 1,234 > 1e3 (1,000).

Expansion depth limit
13 levels allowed:

gives

gives

Internal technical details
For evaluating the condition the template uses the actual parser functions; however, not directly with p and q, because this strips spaces and newlines from them, but with index values 1 and 2. The result can be 1, 2, or an error message. Using a switch these are converted to p1, p2, and if/errmsg, respectively. The template with the applicable name is called (Template:P1, Template:P2, or Template:If/errmsg), with as parameters p, q, and. Templates p1 and p2 ignore ; template if/errmsg is only called in the case of a wrong expression ; it ignores p and q and uses for display in the error message.