Template:Template demo: Difference between revisions
m (Updated documentation) |
(Added (incomplete) support for example captions) |
||
Line 12: | Line 12: | ||
| list = {{#while: | | list = {{#while: | ||
| {{{{{#var: i }} |}}} | | {{{{{#var: i }} |}}} | ||
| <div class="bg3wiki-tooltip-box>'''Markup'''{{Demo|sep='''Renders as<br>'''|nocat=yes|style=margin-top:0px;|tag=pre|{{trim|{{{ {{#var: i}} }}}}}}}</div> | | <div class="bg3wiki-tooltip-box>{{#if:{{{caption {{#var: i}}|}}}|{{{caption {{#var: i}}|}}}<br>}}'''Markup'''{{Demo|sep='''Renders as<br>'''|nocat=yes|style=margin-top:0px;|tag=pre|{{trim|{{{ {{#var: i}} }}}}}}}</div> | ||
{{#vardefine: i | {{#expr: {{#var: i }} + 1 }} }} | {{#vardefine: i | {{#expr: {{#var: i }} + 1 }} }} | ||
}} | }} | ||
Line 85: | Line 85: | ||
}} | }} | ||
</nowiki> | </nowiki> | ||
| caption 2 = You can optionally add additional context or information to examples with {{c|caption <number>}} parameters. | |||
| <nowiki> | | <nowiki> | ||
{{Quote fancy | {{Quote fancy | ||
Line 122: | Line 123: | ||
"example": "<nowiki>{{SAI|Fire Bolt}}</nowiki>", | "example": "<nowiki>{{SAI|Fire Bolt}}</nowiki>", | ||
"type": "content", | "type": "content", | ||
"required": false | |||
}, | |||
"caption 1": { | |||
"label": "Example 1 caption", | |||
"description": "An additional caption or title for the example if you want to add additional context. Currently, only the list style format supports captions.", | |||
"example": "This example demos the {{c|style}} optional parameter.", | |||
"type": "string", | |||
"required": false | |||
}, | |||
"caption 2": { | |||
"label": "Example 2 caption", | |||
"description": "An additional caption or title for the example if you want to add additional context. Currently, only the list style format supports captions.", | |||
"example": "This example demos the {{c|style}} optional parameter.", | |||
"type": "string", | |||
"required": false | |||
}, | |||
"caption 3": { | |||
"label": "And so on...", | |||
"description": "An additional caption or title for the example if you want to add additional context. Currently, only the list style format supports captions.", | |||
"example": "This example demos the {{c|style}} optional parameter.", | |||
"type": "string", | |||
"required": false | "required": false | ||
}, | }, |
Revision as of 20:01, 22 July 2024
This template is designed to easily demo template usage and is intended for use within template documentation pages. It lets you display a set of template examples with the markup and rendered output displayed side-by-side.
Usage
This template has two styles: a two-column table (style = table
) and a list (style = list
). The table is appropriate for shorter, inline templates. For larger templates, the list style may be preferred.
As with Template:Demo on Wikipedia, the arguments to this template must be wrapped in <nowiki>...</nowiki>
tags or the parameters with be expanded before being passed to this template.
Examples
Table style
Select this style with style = table
. It is also the default style used if the optional style parameter is omitted. This style should be used for shorter, inline templates that can fit nicely within a two-column table.
Input
{{Template demo | style = table | <nowiki>{{CharLink|Shadowheart}}</nowiki> | <nowiki>{{DamageText|2d4 + 1|Fire}}</nowiki> | <nowiki>{{RarityItem|Hat of Fire Acuity}}</nowiki> | <nowiki>{{SAI|Fireball}}</nowiki> }}
Output
Markup | Renders as |
---|---|
{{CharLink|Shadowheart}} | Shadowheart |
{{DamageText|2d4 + 1|Fire}} | 2d4 + 1Fire |
{{RarityItem|Hat of Fire Acuity}} | Hat of Fire Acuity |
{{SAI|Fireball}} |
List style
Select this style with style = list
. This should be used to demo templates too large to fit within a table.
Input
{{Template demo | style = list | <nowiki> {{Quote fancy | quote = The operations of these huge steel juggernauts are powered by engines of churning hellfire. | image = Portrait Steel Watcher.png | link = Adamantine Golem }} </nowiki> | <nowiki> {{Quote fancy | quote = These levitating eyes transmit all that they see to the one who created them. | image = Portrait Scrying Eye.png | link = Scrying Eye | height = 60px | rounding = 20% | font-size = 100% }} </nowiki> }}
Output
{{Quote fancy | quote = The operations of these huge steel juggernauts are powered by engines of churning hellfire. | image = Portrait Steel Watcher.png | link = Adamantine Golem }}Renders as
caption <number>
parameters.Markup
{{Quote fancy | quote = These levitating eyes transmit all that they see to the one who created them. | image = Portrait Scrying Eye.png | link = Scrying Eye | height = 60px | rounding = 20% | font-size = 100% }}Renders as
Template data
Display a list of template examples that displays the source wikitext and rendered result side-by-side. The template supports an arbitrary number of examples as unnamed arguments.
Parameter | Description | Type | Status | |
---|---|---|---|---|
Example 1 | 1 | Example markup/wikitext to demo. This parameter must be surrounded by <nowiki> tags to work correctly.
| Content | optional |
Example 2 | 2 | Example markup/wikitext to demo. This parameter must be surrounded by <nowiki> tags to work correctly.
| Content | optional |
And so on... | 3 | Example markup/wikitext to demo. This parameter must be surrounded by <nowiki> tags to work correctly.
| Content | optional |
Example 1 caption | caption 1 | An additional caption or title for the example if you want to add additional context. Currently, only the list style format supports captions.
| String | optional |
Example 2 caption | caption 2 | An additional caption or title for the example if you want to add additional context. Currently, only the list style format supports captions.
| String | optional |
And so on... | caption 3 | An additional caption or title for the example if you want to add additional context. Currently, only the list style format supports captions.
| String | optional |
Style | style | Select the layout style appropriate for the template being demoed.
| String | optional |