Help:Expansion depth/demo

From Meta, a Wikimedia project coordination wiki

Forty levels of nesting are expanded in MediaWiki software. The forty-first level exceeds the expansion depth level and causes an error in its place.

Three templates are used in the demonstration. This template also includes itself to produce the second half of the page.

Template Code Comment
1x {{{1}}} Expand parameter one. A variable template.
Tc in Constant template always returns "in".
Xpdt/3

#if: 0 {{#if:x|1 {{#if:x|2 {{#if:x|3 {{{1}}} 3}} 2}} 1}}

1x: 0 {{1x|1 {{1x|2 {{1x|3 {{{1}}} 3}} 2}} 1}}

Expansion adds three levels of nesting plus any levels in the parameter, before it subtracts three levels plus any levels in the parameter. Its numbers are output in blue and marked by #if: for the parser function part and 1x: for the template.

In the output every number in the sequence except zero represents a change in nesting level. Each section is reduced to level zero.

40 times 1x[edit]

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}} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} 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 in 0

38 times 1x, 2 times #if[edit]

0 {{#if|1 {{#if|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}} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} 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 in 0

35 times 1x, 5 times #if[edit]

0 {{#if:x|1 {{#if:x|2 {{1x|3 {{1x|4 {{#if:x|5 {{1x|6 {{1x|7 {{#if:x|8 {{#if:x|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}} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} 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 in 0

Xpdt/3 at nesting level 3[edit]

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

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

At 1x|4 the nesting level is 7. At 1x|37 the nesting level is 40.

Xpdt/3 at nesting level 17[edit]

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 {{xpdt/3|17 {{1x|18 {{1x|19 {{1x|20 {{tc|1}} 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

1x: 0 1 2 3 17 18 19 20 in 20 19 18 17 3 2 1 0

#if: 0 1 2 3 17 18 19 20 in 20 19 18 17 3 2 1 0 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Xpdt/3 at nesting level 18[edit]

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 {{xpdt/3|18 {{1x|19 {{1x|20 {{tc|1}} 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

1x: 0 1 2 3 18 19 20 in 20 19 18 3 2 1 0

#if: 0 1 2 3 18 19 20 in 20 19 18 3 2 1 0 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Xpdt/3 at nesting level 3, with recursion at 5[edit]

0 {{1x|1 {{1x|2 {{xpdt/3|3 {{1x|4 {{xpdt/3|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 {{tc|1}} 20}} 19}} 18}} 17}} 16}} 15}} 14}} 13}} 12}} 11}} 10}} 9}} 8}} 7}} 6}} 5}} 4}} 3}} 2}} 1}} 0

0 1 2

1x: 0 1 2 3 3 4

1x: 0 1 2 3 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 in 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 3 2 1 0

#if: 0 1 2 3 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 in 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 3 2 1 0 4 3 3 2 1 0

#if: 0 1 2 3 3 4

1x: 0 1 2 3 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 in 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 3 2 1 0

#if: 0 1 2 3 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 in 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 3 2 1 0 4 3 3 2 1 0 2 1 0

Xpdt/3 at nesting level 3, with recursion at 16[edit]

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 {{xpdt/3|16 {{1x|17 {{1x|18 {{1x|19 {{1x|20 {{tc|1}} 20}} 19}} 18}} 17}} 16}} 15}} 14}} 13}} 12}} 11}} 10}} 9}} 8}} 7}} 6}} 5}} 4}} 3}} 2}} 1}} 0

0 1 2

1x: 0 1 2 3 3 4 5 6 7 8 9 10 11 12 13 14 15

1x: 0 1 2 3 16 17 18 19 20 in 20 19 18 17 16 3 2 1 0

#if: 0 1 2 3 16 17 18 19 20 in 20 19 18 17 16 3 2 1 0 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

1x: 0 1 2 3 16 17 18 19 20 in 20 19 18 17 16 3 2 1 0

#if: 0 1 2 3 16 17 18 19 20 in 20 19 18 17 16 3 2 1 0 15 14 13 12 11 10 9 8 7 6 5 4 3 3 2 1 0 2 1 0

This page calling itself[edit]

{{Help:Expansion depth/demo}}

Forty levels of nesting are expanded in MediaWiki software. The forty-first level exceeds the expansion depth level and causes an error in its place.

Three templates are used in the demonstration. This template also includes itself to produce the second half of the page.

Template Code Comment
1x {{{1}}} Expand parameter one. A variable template.
Tc in Constant template always returns "in".
Xpdt/3

#if: 0 {{#if:x|1 {{#if:x|2 {{#if:x|3 {{{1}}} 3}} 2}} 1}}

1x: 0 {{1x|1 {{1x|2 {{1x|3 {{{1}}} 3}} 2}} 1}}

Expansion adds three levels of nesting plus any levels in the parameter, before it subtracts three levels plus any levels in the parameter. Its numbers are output in blue and marked by #if: for the parser function part and 1x: for the template.

In the output every number in the sequence except zero represents a change in nesting level. Each section is reduced to level zero.

40 times 1x[edit]

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}} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} 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 in 0

38 times 1x, 2 times #if[edit]

0 {{#if|1 {{#if|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}} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} 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 in 0

35 times 1x, 5 times #if[edit]

0 {{#if:x|1 {{#if:x|2 {{1x|3 {{1x|4 {{#if:x|5 {{1x|6 {{1x|7 {{#if:x|8 {{#if:x|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}} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} }} 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 in 0

Xpdt/3 at nesting level 3[edit]

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

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

At 1x|4 the nesting level is 7. At 1x|37 the nesting level is 40.

Xpdt/3 at nesting level 17[edit]

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 {{xpdt/3|17 {{1x|18 {{1x|19 {{1x|20 {{tc|1}} 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

1x: 0 1 2 3 17 18 19 20 in 20 19 18 17 3 2 1 0

#if: 0 1 2 3 17 18 19 20 in 20 19 18 17 3 2 1 0 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Xpdt/3 at nesting level 18[edit]

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 {{xpdt/3|18 {{1x|19 {{1x|20 {{tc|1}} 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

1x: 0 1 2 3 18 19 20 in 20 19 18 3 2 1 0

#if: 0 1 2 3 18 19 20 in 20 19 18 3 2 1 0 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Xpdt/3 at nesting level 3, with recursion at 5[edit]

0 {{1x|1 {{1x|2 {{xpdt/3|3 {{1x|4 {{xpdt/3|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 {{tc|1}} 20}} 19}} 18}} 17}} 16}} 15}} 14}} 13}} 12}} 11}} 10}} 9}} 8}} 7}} 6}} 5}} 4}} 3}} 2}} 1}} 0

0 1 2

1x: 0 1 2 3 3 4

1x: 0 1 2 3 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 in 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 3 2 1 0

#if: 0 1 2 3 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 in 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 3 2 1 0 4 3 3 2 1 0

#if: 0 1 2 3 3 4

1x: 0 1 2 3 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 in 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 3 2 1 0

#if: 0 1 2 3 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 in 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 3 2 1 0 4 3 3 2 1 0 2 1 0

Xpdt/3 at nesting level 3, with recursion at 16[edit]

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 {{xpdt/3|16 {{1x|17 {{1x|18 {{1x|19 {{1x|20 {{tc|1}} 20}} 19}} 18}} 17}} 16}} 15}} 14}} 13}} 12}} 11}} 10}} 9}} 8}} 7}} 6}} 5}} 4}} 3}} 2}} 1}} 0

0 1 2

1x: 0 1 2 3 3 4 5 6 7 8 9 10 11 12 13 14 15

1x: 0 1 2 3 16 17 18 19 20 in 20 19 18 17 16 3 2 1 0

#if: 0 1 2 3 16 17 18 19 20 in 20 19 18 17 16 3 2 1 0 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

1x: 0 1 2 3 16 17 18 19 20 in 20 19 18 17 16 3 2 1 0

#if: 0 1 2 3 16 17 18 19 20 in 20 19 18 17 16 3 2 1 0 15 14 13 12 11 10 9 8 7 6 5 4 3 3 2 1 0 2 1 0

This page calling itself[edit]

{{Help:Expansion depth/demo}}