Help:Expansion depth

From Meta, a Wikimedia project coordination wiki

Expansion of templates, parser functions, variables (on this page collectively called templates in italics), and template parameters (tplargs) is subject to an expansion depth limit of 40. It regards the step of producing the expanded wikitext. This step can be isolated from the step of rendering the expanded wikitext by using Special:ExpandTemplates.

The expansion depth is related to the situation that to expand a template or tplarg, expansion of other templates or tplargs is needed. The latter can be in the title or parts in the wikitext to be expanded itself, or in the wikitext of a directly or indirectly called template. How exactly the depth is counted is not always straightforward, see also below.

The highest expansion depth is shown in the limit report in the html source[1]. This improvement of the MediaWiki software was made after what follows was written. This probably makes it easier to investigate expansion depth issues, allowing simpler tests, not exceeding the limit.

The relevant PHP source code includes the preprocessor function "expand", in Manual:Preprocessor DOM.php, which expands a wikitext. If it is a title and variable $expansionDepth (incremented at the start and decremented at the end of the function; inside the function it is incremented through recursion) is greater than mMaxPPExpandDepth then the wikitext <span class="error">Expansion depth limit exceeded</span> rendered as Expansion depth limit exceeded[2] is returned.

As far as the result with the error message can be expanded it is expanded as usual.

In the case of double braces, since "<" and ">" are not allowed in a page title, the braced structure is not transcluded, nor rendered as a link to a non-existing template. However, a parameter tag still works, with the parameter name replaced by the error message.

Examples:

<code>0 {{#tag:nowiki |1 {{#if:x|2 {{#if:x|3 {{#if:x|4 {{#if:x|5 {{#if:x|6 {{#if:x|7 {{#if:x|8 {{#if:x|9 {{#if:x|10 {{#if:x|11 {{#if:x|12 {{#if:x|13 {{#if:x|14 {{#if:x|15 {{#if:x|16 {{#if:x|17 {{#if:x|18 {{#if:x|19 {{#if:x|20 {{#if:x|21 {{#if:x|22 {{#if:x|23 {{#if:x|24 {{#if:x|25 {{#if:x|26 {{#if:x|27 {{#if:x|28 {{#if:x|29 {{#if:x|30 {{#if:x|31 {{#if:x|32 {{#if:x|33 {{#if:x|34 {{#if:x|35 {{#if:x|36 {{#if:x|37 {{#if:x|38 {{#if:x|39 {{#if:x|40 a {{b|c}} {{#if:x|d}} {{PAGENAME}} {{{e}}} {{{e|f}}} {{xpdt/1|g|h}} 40}} {{xpdt/1|i|j}} {{xpdt/25|k}} {{#ifeq:123|{{#if:x|123}}|1|0}} {{#expr:123={{#if:x|123}}}} 40 {{tc}} 39}} 38}} 37}} 36}} 35}} 34}} 33}} 32}} 31}} 30}} 29}} 28}} 27}} 26}} 25}} 24}} 23}} 22}} 21}} 20}} 19}} 18}} 17}} 16}} 15}} 14}} 13}} 12}} 11}} 10}} 9}} 8}} 7}} 6}} 5}} 4}} 3}} 2}} 1}} 0 </code> gives 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 a [[:Template:B]] d Expansion depth {{{e}}} f [[Template:Xpdt/1]]: in g ifx ifin 1xin 40 [[Template:Xpdt/1]]: in i ifx ifin 1xin [[Template:Xpdt/25]]: *'''if:''' 012345678910111213141516171819202122232425k252423222120191817161514131211109876543210 *'''1x:''' 012345678910111213141516171819202122232425k252423222120191817161514131211109876543210 1 1 40 in 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

This demonstrates:

  • The conversion of titles at level 41.
  • Template:Xpdt/1 and even Template:Xpdt/25 called at level 40 work, even though especially the latter has also many parser function levels.
  • When the error message ends up in an expression, the result contains somewhat cryptically an error message about a wrong expression, not about the expansion depth. Worse, when the error message ends up in a condition, the result may be deceptively wrong without any error message.

{{Help:Expansion depth|e=v}} gives:

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 a [[:Template:B]] d Expansion depth v v [[Template:Xpdt/1]]: in g ifx ifin 1xin 40 [[Template:Xpdt/1]]: in i ifx ifin 1xin [[Template:Xpdt/25]]: *'''if:''' 012345678910111213141516171819202122232425k252423222120191817161514131211109876543210 *'''1x:''' 012345678910111213141516171819202122232425k252423222120191817161514131211109876543210 1 1 40 in 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

This shows that parameter e is not effective where it is changed on expansion into the error message. It also shows that calling (the include part of) this page, although creating just one extra level, causes all levels of Template:Xpdt/25 to be counted.

{{Help:Expansion depth|<span class{{=}}"error">Expansion depth limit exceeded</span>=w}} gives:

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 a [[:Template:B]] d Expansion depth {{{e}}} f [[Template:Xpdt/1]]: in g ifx ifin 1xin 40 [[Template:Xpdt/1]]: in i ifx ifin 1xin [[Template:Xpdt/25]]: *'''if:''' 012345678910111213141516171819202122232425k252423222120191817161514131211109876543210 *'''1x:''' 012345678910111213141516171819202122232425k252423222120191817161514131211109876543210 1 1 40 in 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

This shows that occurrences of parameter e which are converted to the error message are effective as parameter with the error message as name.

Nesting depth on the page itself[edit]

To start with, the nesting of templates or tplargs on the page itself cannot be deeper than 40 levels, where a template call is counted once (not once for expanding the template and once for expanding a parameter, the latter is not on the page itself but on the template page, compare the next section).

Thus, for example,

0 {{1x|1 {{1x|2 {{1x|3 {{1x|4 {{1x|5 {{1x|6 {{1x|7 {{1x|8 {{1x|9 {{1x|10 {{1x|11 {{1x|12 {{1x|13 {{1x|14 {{1x|15 {{1x|16 {{1x|17 {{1x|18 {{1x|19 {{1x|20 {{1x|21 {{1x|22 {{1x|23 {{1x|24 {{1x|25 {{1x|26 {{1x|27 {{1x|28 {{1x|29 {{1x|30 {{1x|31 {{1x|32 {{1x|33 {{1x|34 {{1x|35 {{1x|36 {{1x|37 {{1x|38 {{1x|39 {{1x|40 {{tc|1}} 40}} 39}} 38}} 37}} 36}} 35}} 34}} 33}} 32}} 31}} 30}} 29}} 28}} 27}} 26}} 25}} 24}} 23}} 22}} 21}} 20}} 19}} 18}} 17}} 16}} 15}} 14}} 13}} 12}} 11}} 10}} 9}} 8}} 7}} 6}} 5}} 4}} 3}} 2}} 1}} 0

gives

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 in 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

and, replacing two template calls by parser function calls:

0 {{#if:x|1 {{#if:x|2 {{1x|3 {{1x|4 {{1x|5 {{1x|6 {{1x|7 {{1x|8 {{1x|9 {{1x|10 {{1x|11 {{1x|12 {{1x|13 {{1x|14 {{1x|15 {{1x|16 {{1x|17 {{1x|18 {{1x|19 {{1x|20 {{1x|21 {{1x|22 {{1x|23 {{1x|24 {{1x|25 {{1x|26 {{1x|27 {{1x|28 {{1x|29 {{1x|30 {{1x|31 {{1x|32 {{1x|33 {{1x|34 {{1x|35 {{1x|36 {{1x|37 {{1x|38 {{1x|39 {{1x|40 {{tc|1}} 40}} 39}} 38}} 37}} 36}} 35}} 34}} 33}} 32}} 31}} 30}} 29}} 28}} 27}} 26}} 25}} 24}} 23}} 22}} 21}} 20}} 19}} 18}} 17}} 16}} 15}} 14}} 13}} 12}} 11}} 10}} 9}} 8}} 7}} 6}} 5}} 4}} 3}} 2}} 1}} 0

gives

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 in 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 a [[:Template:B]] d Expansion depth {{{e}}} f [[Template:Xpdt/1]]: in g ifx ifin 1xin 40 [[Template:Xpdt/1]]: in i ifx ifin 1xin [[Template:Xpdt/25]]: *'''if:''' 012345678910111213141516171819202122232425k252423222120191817161514131211109876543210 *'''1x:''' 012345678910111213141516171819202122232425k252423222120191817161514131211109876543210 1 1 40 in 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 gives 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 a {{Expansion depth limit exceeded|c}} {{Expansion depth limit exceeded|d}} {{Expansion depth limit exceeded}} {{{Expansion depth limit exceeded}}} f {{Expansion depth limit exceeded|g|h}} 40 Template:Xpdt/1: in i ifx ifin 1xin Template:Xpdt/25: *if: 012345678910111213141516171819202122232425k252423222120191817161514131211109876543210 *1x: 01234567891011121314151617181920{{Expansion depth limit exceeded|21{{Expansion depth limit exceeded|22{{Expansion depth limit exceeded|23{{Expansion depth limit exceeded|24{{Expansion depth limit exceeded|25{{{Expansion depth limit exceeded}}}25}}24}}23}}22}}21}}20191817161514131211109876543210 0 Expression error: Unrecognized punctuation character "{". 40 in 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 /* Nesting depth on the page itself */

Caching[edit]

If on a page the same template is called more than once without parameters, the first result is cached. It may have been cached before too. Thus, when investigating expansion depth issues, always call all templates with a parameter, even if the template body does not contain any parameter tags.

Overall nesting depth[edit]

In a chain of nested templates, where at every level except the last, a parameter of the template contains a call to the next template in the chain, the overall depth also depends of the depths inside the templates. The previous section dealt with the simplest case, such as Template:1x, counting for 1, allowing a chain of length 40 containing any mix of parser functions and such basic templates.

When a template in the chain has itself a nesting of templates and/or parser functions, with at the end a parameter (with as value the remaining chain on the root page), the extra template calls are counted twice and the extra parser function calls once. However, a number of levels equal to the number of extra template calls can be reused for levels in the chain on the root page beyond this template.

For example:


0 {{1x|1 {{1x|2 {{xpdt/3|3 {{1x|4 {{1x|5 {{1x|6 {{1x|7 {{1x|8 {{1x|9 {{1x|10 {{1x|11 {{1x|12 {{1x|13 {{1x|14 {{1x|15 {{1x|16 {{1x|17 {{1x|18 {{1x|19 {{1x|20 {{1x|21 {{1x|22 {{1x|23 {{1x|24 {{1x|25 {{1x|26 {{1x|27 {{1x|28 {{1x|29 {{1x|30 {{1x|31 {{1x|32 {{1x|33 {{1x|34 {{1x|35 {{1x|36 {{1x|37 {{1x|38 {{1x|39 {{1x|40 {{tc|1}} 40}} 39}} 38}} 37}} 36}} 35}} 34}} 33}} 32}} 31}} 30}} 29}} 28}} 27}} 26}} 25}} 24}} 23}} 22}} 21}} 20}} 19}} 18}} 17}} 16}} 15}} 14}} 13}} 12}} 11}} 10}} 9}} 8}} 7}} 6}} 5}} 4}} 3}} 2}} 1}} 0

gives

0 1 2

1x: 0 1 2 3 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 in 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 3 2 1 0

#if: 0 1 2 3 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 in 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 3 2 1 0 2 1 0


0 {{1x|1 {{1x|2 {{1x|3 {{1x|4 {{1x|5 {{1x|6 {{1x|7 {{1x|8 {{1x|9 {{1x|10 {{1x|11 {{1x|12 {{1x|13 {{1x|14 {{1x|15 {{1x|16 {{1x|17 {{1x|18 {{1x|19 {{1x|20 {{1x|21 {{1x|22 {{1x|23 {{1x|24 {{1x|25 {{1x|26 {{1x|27 {{1x|28 {{1x|29 {{1x|30 {{1x|31 {{1x|32 {{1x|33 {{xpdt/3|34 {{1x|35 {{1x|36 {{1x|37 {{1x|38 {{1x|39 {{1x|40 {{tc|1}} 40}} 39}} 38}} 37}} 36}} 35}} 34}} 33}} 32}} 31}} 30}} 29}} 28}} 27}} 26}} 25}} 24}} 23}} 22}} 21}} 20}} 19}} 18}} 17}} 16}} 15}} 14}} 13}} 12}} 11}} 10}} 9}} 8}} 7}} 6}} 5}} 4}} 3}} 2}} 1}} 0

gives

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33

1x: 0 1 2 3 34 35 36 37 38 39 40 in 40 39 38 37 36 35 34 3 2 1 0

#if: 0 1 2 3 34 35 36 37 38 39 40 in 40 39 38 37 36 35 34 3 2 1 0 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0


0 {{1x|1 {{1x|2 {{1x|3 {{1x|4 {{1x|5 {{1x|6 {{1x|7 {{1x|8 {{1x|9 {{1x|10 {{1x|11 {{1x|12 {{1x|13 {{1x|14 {{1x|15 {{1x|16 {{1x|17 {{1x|18 {{1x|19 {{1x|20 {{1x|21 {{1x|22 {{1x|23 {{1x|24 {{1x|25 {{1x|26 {{1x|27 {{1x|28 {{1x|29 {{1x|30 {{1x|31 {{1x|32 {{1x|33 {{1x|34 {{xpdt/3|35 {{1x|36 {{1x|37 {{1x|38 {{1x|39 {{1x|40 {{tc|1}} 40}} 39}} 38}} 37}} 36}} 35}} 34}} 33}} 32}} 31}} 30}} 29}} 28}} 27}} 26}} 25}} 24}} 23}} 22}} 21}} 20}} 19}} 18}} 17}} 16}} 15}} 14}} 13}} 12}} 11}} 10}} 9}} 8}} 7}} 6}} 5}} 4}} 3}} 2}} 1}} 0

gives

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34

1x: 0 1 2 3 35 36 37 38 39 40 in 40 39 38 37 36 35 3 2 1 0

#if: 0 1 2 3 35 36 37 38 39 40 in 40 39 38 37 36 35 3 2 1 0 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0


0 {{1x|1 {{1x|2 {{1x|3 {{1x|4 {{1x|5 {{1x|6 {{1x|7 {{1x|8 {{1x|9 {{1x|10 {{1x|11 {{1x|12 {{1x|13 {{1x|14 {{1x|15 {{1x|16 {{1x|17 {{1x|18 {{1x|19 {{1x|20 {{1x|21 {{1x|22 {{1x|23 {{1x|24 {{1x|25 {{1x|26 {{1x|27 {{1x|28 {{1x|29 {{1x|30 {{1x|31 {{1x|32 {{1x|33 {{1x|34 {{1x|35 {{xpdt/3|36 {{1x|37 {{1x|38 {{1x|39 {{1x|40 {{tc|1}} 40}} 39}} 38}} 37}} 36}} 35}} 34}} 33}} 32}} 31}} 30}} 29}} 28}} 27}} 26}} 25}} 24}} 23}} 22}} 21}} 20}} 19}} 18}} 17}} 16}} 15}} 14}} 13}} 12}} 11}} 10}} 9}} 8}} 7}} 6}} 5}} 4}} 3}} 2}} 1}} 0

gives

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35

1x: 0 1 2 3 36 37 38 39 40 in 40 39 38 37 36 3 2 1 0

#if: 0 1 2 3 36 37 38 39 40 in 40 39 38 37 36 3 2 1 0 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0


0 {{1x|1 {{1x|2 {{1x|3 {{1x|4 {{1x|5 {{1x|6 {{1x|7 {{1x|8 {{1x|9 {{1x|10 {{1x|11 {{1x|12 {{1x|13 {{1x|14 {{1x|15 {{1x|16 {{1x|17 {{1x|18 {{1x|19 {{1x|20 {{1x|21 {{1x|22 {{1x|23 {{1x|24 {{1x|25 {{1x|26 {{1x|27 {{1x|28 {{1x|29 {{1x|30 {{1x|31 {{1x|32 {{1x|33 {{1x|34 {{1x|35 {{1x|36 {{xpdt/3|37 {{1x|38 {{1x|39 {{1x|40 {{tc|1}} 40}} 39}} 38}} 37}} 36}} 35}} 34}} 33}} 32}} 31}} 30}} 29}} 28}} 27}} 26}} 25}} 24}} 23}} 22}} 21}} 20}} 19}} 18}} 17}} 16}} 15}} 14}} 13}} 12}} 11}} 10}} 9}} 8}} 7}} 6}} 5}} 4}} 3}} 2}} 1}} 0

gives

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36

1x: 0 1 2 3 37 38 39 40 in 40 39 38 37 3 2 1 0

#if: 0 1 2 3 37 38 39 40 in 40 39 38 37 3 2 1 0 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0


Thus, for the 1x branch, if 7 remaining levels are available at the level of the xpdt/3, this is enough, and 3 levels are reused for levels beyond this templates. By contrast, if only 6 remaining levels are available at the level of the xpdt/3, this is not enough, the parameter is not expanded, so anything in the chain on the root page beyond this template (i.e., at a deeper level, serving as value for the parameter) is discarded.

Transcluding a template[edit]

Consider the special case of a page transcluding a template. This is a "chain" of length 1. When this template has a nesting of templates and/or parser functions, with at the end a parameter, these template calls are counted twice and these parser function calls once, see Help:Expansion depth/demo.

As the demo shows, the template can, for example, have 20 nested basic templates. If one of the nested templated is Template:Xpdt/3 (with three extra transclusion levels), the chain can contain together up to 18 templates ((40-3)/2, rounded down), while xpdt/3 cannot be the 18th position in the chain. If two are xpdt/3, the chain can contain together up to 17 templates ((40-6)/2), while the second xpdt/3 cannot be beyond the 15th position in the chain.

More generally, if the template contains a chain of m templates like the 1x-branch of xpdt/nk (for nk=0: like 1x) the restriction is that for every k with 1 ≤ k ≤ m the sum of (ni+2) over all i with 1 ≤ i ≤ k, plus nk, is less than or equal to 40.

Edt[edit]

In the following example this page calls Template:Edt, which calls Template:Xpdt/25. First there is the expansion of Edt, then of its parameter 1, then 0 or more calls of #if or 1x, then the expansion of template Xpdt/25.

The 1x-part of the first item succeeds in the expansion of a chain of 19 expansions of template 1x and its parameter, and another expansion of template 1x without expanding its parameter. The 1x-part of the second item has extra one expansion of 1x and its parameter in Edt, and one less of each in Xpdt/25, etc. The if-part of item 8 has 7 expansions of 1x and its parameter in Edt, and 25 expansions of parser function #if in Xpdt/25. The if-part of item 9 has 8 expansions of 1x and its parameter in Edt, and 23 expansions of #if in Xpdt/25, etc. Thus, not counting the expansion of Edt and its parameter 1, and of template Xpdt/25, there is in all cases a depth of 39 expansions. Comparing this with the previous example we see that the expansion of parameter 1 of Edt does not contribute to the expansion depth. Comparing with the earlier examples we see that the extra template is counted, since a depth of 39 remains, while before is was 40. w:Template:Transclusion depth test also indicates that in a chain of templates each counts as 1.

Item 21 has 20 expansions of 1x and its parameter in Edt, and no expansion of Edt. Thus, not counting the expansion of Edt and its parameter 1, there is a depth of 40 expansions.

{{edt|xpdt/25}} gives:

Expansion depth test (purge)

edt 0

Template:Xpdt/25:

  • if: 0123456789101112131415161718192021222324251252423222120191817161514131211109876543210
  • 1x: 0123456789101112131415161718192021222324251252423222120191817161514131211109876543210


edt 1

Template:Xpdt/25:

  • if: 0123456789101112131415161718192021222324251252423222120191817161514131211109876543210
  • 1x: 0123456789101112131415161718192021222324251252423222120191817161514131211109876543210


edt 2

Template:Xpdt/25:

  • if: 0123456789101112131415161718192021222324251252423222120191817161514131211109876543210
  • 1x: 0123456789101112131415161718192021222324251252423222120191817161514131211109876543210


edt 3

Template:Xpdt/25:

  • if: 0123456789101112131415161718192021222324251252423222120191817161514131211109876543210
  • 1x: 0123456789101112131415161718192021222324251252423222120191817161514131211109876543210


edt 4

Template:Xpdt/25:

  • if: 0123456789101112131415161718192021222324251252423222120191817161514131211109876543210
  • 1x: 0123456789101112131415161718192021222324251252423222120191817161514131211109876543210


edt 5

Template:Xpdt/25:

  • if: 0123456789101112131415161718192021222324251252423222120191817161514131211109876543210
  • 1x: 0123456789101112131415161718192021222324251252423222120191817161514131211109876543210


edt 6

Template:Xpdt/25:

  • if: 0123456789101112131415161718192021222324251252423222120191817161514131211109876543210
  • 1x: 0123456789101112131415161718192021222324251252423222120191817161514131211109876543210


edt 7

Template:Xpdt/25:

  • if: 0123456789101112131415161718192021222324251252423222120191817161514131211109876543210
  • 1x: 0123456789101112131415161718192021222324251252423222120191817161514131211109876543210


edt 8

Template:Xpdt/25:

  • if: 0123456789101112131415161718192021222324251252423222120191817161514131211109876543210
  • 1x: 0123456789101112131415161718192021222324251252423222120191817161514131211109876543210


edt 9

Template:Xpdt/25:

  • if: 0123456789101112131415161718192021222324251252423222120191817161514131211109876543210
  • 1x: 0123456789101112131415161718192021222324251252423222120191817161514131211109876543210


edt 10

Template:Xpdt/25:

  • if: 0123456789101112131415161718192021222324251252423222120191817161514131211109876543210
  • 1x: 0123456789101112131415161718192021222324251252423222120191817161514131211109876543210


edt 11

Template:Xpdt/25:

  • if: 0123456789101112131415161718192021222324251252423222120191817161514131211109876543210
  • 1x: 0123456789101112131415161718192021222324251252423222120191817161514131211109876543210


edt 12

Template:Xpdt/25:

  • if: 0123456789101112131415161718192021222324251252423222120191817161514131211109876543210
  • 1x: 0123456789101112131415161718192021222324251252423222120191817161514131211109876543210


edt 13

Template:Xpdt/25:

  • if: 0123456789101112131415161718192021222324251252423222120191817161514131211109876543210
  • 1x: 0123456789101112131415161718192021222324251252423222120191817161514131211109876543210


edt 14

Template:Xpdt/25:

  • if: 0123456789101112131415161718192021222324251252423222120191817161514131211109876543210
  • 1x: 0123456789101112131415161718192021222324251252423222120191817161514131211109876543210


edt 15

Template:Xpdt/25:

  • if: 0123456789101112131415161718192021222324251252423222120191817161514131211109876543210
  • 1x: 0123456789101112131415161718192021222324251252423222120191817161514131211109876543210


edt 16

Template:Xpdt/25:

  • if: 0123456789101112131415161718192021222324251252423222120191817161514131211109876543210
  • 1x: 0123456789101112131415161718192021222324251252423222120191817161514131211109876543210


edt 17

Template:Xpdt/25:

  • if: 0123456789101112131415161718192021222324251252423222120191817161514131211109876543210
  • 1x: 0123456789101112131415161718192021222324251252423222120191817161514131211109876543210


edt 18

Template:Xpdt/25:

  • if: 0123456789101112131415161718192021222324251252423222120191817161514131211109876543210
  • 1x: 0123456789101112131415161718192021222324251252423222120191817161514131211109876543210


edt 19

Template:Xpdt/25:

  • if: 0123456789101112131415161718192021222324251252423222120191817161514131211109876543210
  • 1x: 0123456789101112131415161718192021222324251252423222120191817161514131211109876543210



A way of reducing expansion depth of a versatile template is splitting it up, as has been partially done with Template:If. See also the following subsection.

Switch[edit]

A single #switch is effectively a nesting of branching functions, without counting each level. Thus in some cases a nesting of branching functions can be replaced by a switch, reducing the depth count.

For example:

  • {{#switch:1|condition1=branch1|condition2=branch2|condition3=branch3|branch4}}

is equivalent with

  • {{#ifexpr:condition1|branch1|{{#ifexpr:condition2|branch2|{{#ifexpr:condition3|branch3|branch4}}}}}}

See also[edit]

  1. MediaWiki revision: Show Highest expansion depth in limit report
  2. The message is explicitly given the source code, not as a reference to a system message in the MediaWiki namespace. There is also message with id 'parser-template-recursion-depth-warning' (talk).

Links to other help pages

Help contents
Meta · Wikinews · Wikipedia · Wikiquote · Wiktionary · Commons: · Wikidata · MediaWiki · Wikibooks · Wikisource · MediaWiki: Manual · Google
Versions of this help page (for other languages see further)
What links here on Meta or from Meta · Wikipedia · MediaWiki
Reading
Go · Search · Namespace · Page name · Section · Backlinks · Redirect · Category · Image page · Special pages · Printable version
Tracking changes
Recent changes (enhanced) | Related changes · Watching pages · Diff · Page history · Edit summary · User contributions · Minor edit · Patrolled edit
Logging in and preferences
Logging in · Preferences
Editing
Starting a new page · Advanced editing · Editing FAQ · Export · Import · Shortcuts · Edit conflict · Page size
Referencing
Links · URL · Piped links · Interwiki linking · Footnotes
Style and formatting
Wikitext examples · CSS · Reference card · HTML in wikitext · Formula · Lists · Table · Sorting · Colors · Images and file uploads
Fixing mistakes
Show preview · Reverting edits
Advanced functioning
Expansion · Template · Advanced templates · Parser function · Parameter default · Magic words · System message · Substitution · Array · Calculation · Transclusion
Others
Special characters · Renaming (moving) a page · Preparing a page for translation · Talk page · Signatures · Sandbox · Legal issues for editors
Other languages: