Help:Expansion demo templates

The expansion demo templates show, for documentation:
 * some wikitext
 * its rendering
 * a link to ExpandTemplates applied to the wikitext; thus it shows:
 * The expanded wikitext; this differs from the wikitext if that contains the call of a variable, parser function or template.
 * The rendering of this expanded wikitext (the result of expanding again, and further processing); this is typically the same as how the wikitext is rendered (the result of expanding once and further processing), because typically expanding again causes no further changes. However, there are exceptions; e.g. when calling : txpd.

Usage:
 * - with the template linked
 * - with the template linked

The characters "|" and "=" and the double braces "" cannot be part of the parameters. Such components of the wikitext determine the pattern. Note that this does not apply for the colon, so e.g. in a parser function everything between the opening braces and the colon, such as "#ifeq:abc", can be taken together as one parameter of xpd, and the pattern is the same as when this is replaced by a template name.

The rendering is based on inline use of the supplied wikitext. To see the result when it is at the start of a new line, put a newline in the wikitext (in a separate parameter, see below). Thus, but. The automatic newline feature/bug applies as usual.

Supported patterns
Below are the supported patterns. There is a separate template for each, because a combined template page gets slow due to all examples, while there is little advantage in having them combined.

Naming scheme:
 * o = double opening braces
 * c = double closing braces
 * p = pipe character
 * e = equals sign
 * number = number of text parameters (at the start: instead of none; elsewhere: instead of one), to allow a space or newline as value of a separate parameter (this is required for proper processing)

Additional parameters

 * The parameter gives can be assigned a text (or the empty string) to replace the word "gives", e.g. gives= || to produce "||", for use in a table.
 * By default quotation marks are used both around the wikitext and around the result. This is especially useful to show blank spaces and newlines. The optional parameter d can change this delimiter, e.g. "d=" to make it the empty string. Note however that the result including the delimiters is trimmed; this does not affect the default case, but may affect the result if the delimiter is empty, or if the delimiter itself has a newline or space at the start or end.

Examples
Examples without additional parameters:

If the left side contains an equals sign, the named parameter 1 can and should be used:

Equals sign in another parameter: see below.

Expression in double braces which itself includes a pair of double braces (simple nested expressions): use xpdoocc, with "|" for the inner " ". see also

Examples with additional parameters (no nesting possible):

For the examples below see also the edit box.

Characters in a separate parameter, and combinations of characters together in a separate parameter
Some characters need to be in a separate parameter, and some combinations of characters need to be together in a separate parameter, so that the template can recognize them and handle them separately:

A newline needs to be in a separate parameter, otherwise it is displayed as a space, while the result takes into account the newline:

gives:

(correct)

gives:

(the resulting statement is with respect to the separation between a and b by itself correct, but not what was supposed to be demonstrated, and with respect to the separation between b and c even wrong)

Selection of pattern
The expansion demo template does not check whether it is the correct one for the pattern of the wikitext. Assume that the wikitext which is the subject of the demonstration contains double braces, but that, due to separation with "|" and the wrong choice of the expansion demo template, they are treated as plain text in the expansion of the expansion demo template call. Then the produced message "..." gives "..." is not correct, because in the expansion of the wikitext at the first set of dots the double braces would be interpreted as template braces etc. Example:

gives:



although in reality (as shown when selecting the correct expansion demo template xpdoc):



Technical background
Each template calls Template:Xpda. See there for more technical explanation.

Notes:
 * Some of the expansion demo templates still specify p=pattern in the call of Template:Xpda. However, this parameter is no longer used and can be removed.
 * Some of the expansion demo templates still specify  in the call of Template:Xpda. However, this is being replaced by   while moving the   to the start of result. This avoids trimming on the left side of the result if delimiter d is specified as the empty string; this trimming is especially inconvenient if the result is a table: quotes do not look good, but the newline before " " is needed.