Markup
{{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
m (Added linebreak in the list style output) |
mNo edit summary |
||
(10 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
<includeonly>{{# | <includeonly>{{#lvardef: i | 1 }}{{#switch:{{{style|table}}} | ||
| table = <table class="wikitable"> | | table = <table class="wikitable"> | ||
<tr> | <tr> | ||
<!-- TODO: Improve the logic for determining if the table should have a caption column --> | |||
{{#if: {{{caption 1|}}}|<th>Example</th>}} | |||
<th>Markup</th> | <th>Markup</th> | ||
<th>Renders as</th> | <th>Renders as</th> | ||
</tr> | </tr> | ||
{{#while: | {{#while: | ||
| {{{{{# | | {{{{{#lvar: i }} |}}} | ||
| <tr><td>{{Demo|sep=</td><td>|nocat=yes|tag=pre|style=margin:0px;border:0px;|{{trim|{{{ {{# | | <tr> | ||
{{# | {{#if:{{{caption {{#lvar: i }}|}}}|<th>{{{caption {{#lvar: i }}|}}}</th>}} | ||
<td>{{Demo|sep=</td><td>|nocat=yes|tag=pre|style=margin:0px;border:0px;|{{trim|{{{ {{#lvar: i}} }}}}}}}</td> | |||
</tr> | |||
{{#lvardef: i | {{#expr: {{#lvar: i }} + 1 }} }} | |||
}}</table> | }}</table> | ||
| list = {{#while: | | list = {{#while: | ||
| {{{{{# | | {{{{{#lvar: i }} |}}} | ||
| <div class="bg3wiki-tooltip-box>'''Markup'''{{Demo|sep='''Renders as<br>'''|nocat=yes|style=margin-top:0px;|tag=pre|{{trim|{{{ {{# | | <div class="bg3wiki-tooltip-box>{{#if:{{{caption {{#lvar: i}}|}}}|<p>{{{caption {{#lvar: i}}|}}}</p>}}'''Markup'''{{Demo|sep='''Renders as<br>'''|nocat=yes|style=margin-top:0px;|tag=pre|{{trim|{{{ {{#lvar: i}} }}}}}}}</div> | ||
{{# | {{#lvardef: i | {{#expr: {{#lvar: i }} + 1 }} }} | ||
}} | }} | ||
| #default = Unknown style option <code>{{{style|}}}</code>. Expected <code>table</code> (default) or <code> | |||
| tabbed | tab = {{#tag: tabber | {{#while: | |||
| {{{{{#lvar: i }} |}}} | |||
| {{!}}-{{!}} {{{ caption {{#lvar: i}} | Example {{#lvar: i}} }}} = '''Markup'''{{Demo|sep='''Renders as<br>'''|nocat=yes|style=margin-top:0px;|tag=pre|{{trim|{{{ {{#lvar: i}} }}}}}}} | |||
{{#lvardef: i | {{#expr: {{#lvar: i }} + 1 }} }} | |||
}}}} | |||
| #default = Unknown style option <code>{{{style|}}}</code>. Expected <code>table</code> (default), <code>list</code>, or <code>tabbed</code>. | |||
}}</includeonly><noinclude>{{documentation|content= | }}</includeonly><noinclude>{{documentation|content= | ||
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. | 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 == | == Usage == | ||
This template has | This template has three styles: a two-column table (<code>style = table</code>), a list (<code>style = list</code>), or a tabbed(<code>style = tabbed</code>). The table is appropriate for shorter, inline templates. For larger templates, the list style may be preferred. For exceptionally long templates like page generators, tabbed style may be preferred. | ||
As with | As with {{Wikipedia|Template:Demo}}, the arguments to this template {{em|must}} be wrapped in <code><nowiki><nowiki>...</nowiki</nowiki><nowiki>></nowiki></code> tags or the parameters will be expanded before being passed to this template. | ||
== Examples == | == Examples == | ||
Line 45: | Line 58: | ||
| <nowiki>{{DamageText|2d4 + 1|Fire}}</nowiki> | | <nowiki>{{DamageText|2d4 + 1|Fire}}</nowiki> | ||
| <nowiki>{{RarityItem|Hat of Fire Acuity}}</nowiki> | | <nowiki>{{RarityItem|Hat of Fire Acuity}}</nowiki> | ||
| <nowiki>{{SAI|Fireball}}</nowiki> | |||
}} | |||
=== Table style with captions === | |||
If you want to add captions to the examples, you can do so with {{c|caption <number>}} parameters. This switches to a 3 column layout. | |||
==== Input ==== | |||
<!-- Can't recursively use this template to demo itself. Sad ---> | |||
<pre> | |||
{{Template demo | |||
| style = table | |||
| caption 1 = CharLink demo | |||
| <nowiki>{{CharLink|Shadowheart}}</nowiki> | |||
| caption 2 = DamageText demo | |||
| <nowiki>{{DamageText|2d4 + 1|Fire}}</nowiki> | |||
| caption 3 = RarityItem demo | |||
| <nowiki>{{RarityItem|Hat of Fire Acuity}}</nowiki> | |||
| caption 4 = SAI demo | |||
| <nowiki>{{SAI|Fireball}}</nowiki> | |||
}} | |||
</pre> | |||
==== Output ==== | |||
{{Template demo | |||
| style = table | |||
| caption 1 = CharLink demo | |||
| <nowiki>{{CharLink|Shadowheart}}</nowiki> | |||
| caption 2 = DamageText demo | |||
| <nowiki>{{DamageText|2d4 + 1|Fire}}</nowiki> | |||
| caption 3 = RarityItem demo | |||
| <nowiki>{{RarityItem|Hat of Fire Acuity}}</nowiki> | |||
| caption 4 = SAI demo | |||
| <nowiki>{{SAI|Fireball}}</nowiki> | | <nowiki>{{SAI|Fireball}}</nowiki> | ||
}} | }} | ||
=== List style === | === List style === | ||
Select this style with <code>style = list</code>. This should be used to demo templates too large to fit within a table. | Select this style with <code>style = list</code>. This should be used to demo templates too large to fit within a table. You can also optionally caption the examples as with the table style. | ||
<!-- Can't recursively use this template to demo itself. Sad ---> | <!-- Can't recursively use this template to demo itself. Sad ---> | ||
==== Input ==== | ==== Input ==== | ||
Line 62: | Line 106: | ||
}} | }} | ||
</nowiki> | </nowiki> | ||
| caption 2 = This example demonstrates many of the optional style parameters. | |||
| <nowiki> | | <nowiki> | ||
{{Quote fancy | {{Quote fancy | ||
Line 78: | Line 123: | ||
{{Template demo | {{Template demo | ||
| style = list | | 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> | |||
| caption 2 = This example demonstrates many of the optional style parameters. | |||
| <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> | |||
}} | |||
=== Tabbed style === | |||
Select this style with <code>style = tabbed</code>. Tabbed style is good for exceptionally long templates such as page generators. | |||
==== Input ==== | |||
<pre> | |||
{{Template demo | |||
| style = tabbed | |||
| <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> | |||
}} | |||
</pre> | |||
==== Output ==== | |||
{{Template demo | |||
| style = tabbed | |||
| <nowiki> | | <nowiki> | ||
{{Quote fancy | {{Quote fancy | ||
Line 105: | Line 199: | ||
"1": { | "1": { | ||
"label": "Example 1", | "label": "Example 1", | ||
"description": "Example markup/wikitext to demo.", | "description": "Example markup/wikitext to demo. This parameter must be surrounded by <nowiki> tags to work correctly.", | ||
"example": "<nowiki>{{SAI|Fire Bolt}}</nowiki>", | |||
"type": "content", | "type": "content", | ||
"required": false | "required": false | ||
Line 111: | Line 206: | ||
"2": { | "2": { | ||
"label": "Example 2", | "label": "Example 2", | ||
"description": "Example markup/wikitext to demo.", | "description": "Example markup/wikitext to demo. This parameter must be surrounded by <nowiki> tags to work correctly.", | ||
"example": "<nowiki>{{SAI|Fire Bolt}}</nowiki>", | |||
"type": "content", | "type": "content", | ||
"required": false | "required": false | ||
}, | }, | ||
"3 | "3": { | ||
"label": "And so on...", | "label": "And so on...", | ||
"description": "Example markup/wikitext to demo.", | "description": "Example markup/wikitext to demo. This parameter must be surrounded by <nowiki> tags to work correctly.", | ||
"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.", | |||
"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.", | |||
"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.", | |||
"example": "This example demos the {{c|style}} optional parameter.", | |||
"type": "string", | |||
"required": false | "required": false | ||
}, | }, |
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.
This template has three styles: a two-column table (style = table
), a list (style = list
), or a tabbed(style = tabbed
). The table is appropriate for shorter, inline templates. For larger templates, the list style may be preferred. For exceptionally long templates like page generators, tabbed style may be preferred.
As with Template:Demo, the arguments to this template must be wrapped in
<nowiki>...</nowiki>
tags or the parameters will be expanded before being passed to this template.
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.
{{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> }}
Markup | Renders as |
---|---|
{{CharLink|Shadowheart}} | ![]() |
{{DamageText|2d4 + 1|Fire}} | 2d4 + 1![]() |
{{RarityItem|Hat of Fire Acuity}} | ![]() |
{{SAI|Fireball}} | ![]() |
If you want to add captions to the examples, you can do so with caption <number>
parameters. This switches to a 3 column layout.
{{Template demo | style = table | caption 1 = CharLink demo | <nowiki>{{CharLink|Shadowheart}}</nowiki> | caption 2 = DamageText demo | <nowiki>{{DamageText|2d4 + 1|Fire}}</nowiki> | caption 3 = RarityItem demo | <nowiki>{{RarityItem|Hat of Fire Acuity}}</nowiki> | caption 4 = SAI demo | <nowiki>{{SAI|Fireball}}</nowiki> }}
Example | Markup | Renders as |
---|---|---|
CharLink demo | {{CharLink|Shadowheart}} | ![]() |
DamageText demo | {{DamageText|2d4 + 1|Fire}} | 2d4 + 1![]() |
RarityItem demo | {{RarityItem|Hat of Fire Acuity}} | ![]() |
SAI demo | {{SAI|Fireball}} | ![]() |
Select this style with style = list
. This should be used to demo templates too large to fit within a table. You can also optionally caption the examples as with the table style.
{{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> | caption 2 = This example demonstrates many of the optional style parameters. | <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> }}
{{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
This example demonstrates many of the optional style 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
Select this style with style = tabbed
. Tabbed style is good for exceptionally long templates such as page generators.
{{Template demo | style = tabbed | <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> }}
Markup
{{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
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
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.
| String | optional |
Example 2 caption | caption 2 | An additional caption or title for the example if you want to add additional context.
| String | optional |
And so on... | caption 3 | An additional caption or title for the example if you want to add additional context.
| String | optional |
Style | style | Select the layout style appropriate for the template being demoed.
| String | optional |