Template:Example/start/doc
This is a template for creating formatted Example boxes, e.g. for example wand builds. The examples are automatically numbered, can be given anchor permalinks and can be included in other pages using Labeled Section Transclusion.
Example box:
{{Example/start}}
{{Example/end}}
Results box:
Usage
Create
{{example/start|anchor=anchor_id|title=Some title|heading=2|toc=0}}
Example contents, text, templates etc.
{{example/result/start}}
A result of some calculation or markup.
{{example/result/end}}
{{example/end}}
Linking
On page "SomeArticle", with {{example/start|anchor=Foo}}
[[#Foo]]
- link within the page[[SomeArticle#Foo]]
- link from elsewhere[[SomeArticle#Foo | Foo Example]]
- custom link text
Transclusion
Each example comes wrapped in a <section>
, allowing it to be transcluded into other pages. The section label is the same as the anchor.
Parameters
- All parameters are optional, defaults used if they are omitted
Parameter | Default | Description |
---|---|---|
anchor |
Sequential | Must be unique on the page. If specified, will be used as a second, named anchor to the Example, which can be used to link to it. This is in addition to the auto-generated, sequential anchor. Note: Sequentially generated anchors will change based on the order and number of examples on the page. If no |
title |
Example N: |
Add a title to the example, which will be inserted following the 'Example N:' default text. This title is also used when listing the example in the page's table of contents. If no |
heading |
0 |
Sets the base heading level for this example - the nesting depth is added to this base to give the actual heading level.
Set to |
toc |
1 |
Sets the maximum nesting level for examples to be included in the page table of contents (TOC). Defaults to 1 , which means that this example will be included if it is not nested. Set to 0 to exclude the example from the TOC. Set to 2 or higher to include nested Examples.
|
Notes:
- Nested examples will be numbered within their nesting section (like:
1.1
,1.2
etc.) - While an arbitrary level of nesting will work, I can't really see much use for it with this template.
Usage examples
Note how the title is used to create the anchor and transclusion links, in absence of the anchor
parameter.
{{example/start|title=Teleport Wand}}
This is an example of a teleport wand.
{{Wand
| capacity = 7
| spell1 = Double Spell
| spell2 = Reduce Lifetime
| spell3 = Long-Distance Cast
| spell4 = Add Mana
| spell5 = Nolla
| spell6 = Small Teleport Bolt
| spell7 = Chainsaw
}}
{{example/end}}
Note that the anchor link comes from the anchor
param, not the title
.
{{example/start|title=My Title|anchor=Some Anchor}}
You can embed a Wand build directly into a wiki page using {{tl|Wand}}
{{example/result/start}}
{{Wand}}
{{example/result/end}}
{{example/end}}
This example has a heading level of 1, which equates to h2 level without nesting.
This example has a heading level of 3, which equates to h3 level without nesting.
This example has a heading level of 4, which equates to h4 level without nesting.
This example has a heading level of 5, which equates to h5 level without nesting.
This example has a heading level of 6, which equates to h6 level without nesting.
Non-nested examples, by default, create section links/entries in the TOC. Disable this with toc=0
.
{{example/start|anchor=egA}}
This example is more deeply nested. By default it is omitted from the TOC.
{{example/end}}
{{example/start|anchor=egA|toc=2}}
This example is included, thanks to <code>toc=2</code>.
{{example/end}}
{{example/start|anchor=egAA}}
This example is more deeply nested.
{{example/start|anchor=egAAA|toc=4}}
This example is more deeply nested.
{{example/start|anchor=egAAA}}
This example is probably too deeply nested.
{{example/end}}
{{example/end}}
{{example/end}}
{{example/end}}
{{example/start|anchor=egB|toc=0}}
This example is at the top level, but not included in the TOC.
{{example/end}}
This example is more deeply nested. By default it is omitted from the TOC.
This example is included, thanks to toc=2
.
This example is at the top level, but not included in the TOC.