Ad placeholder

Template:Template demo: Difference between revisions

Jump to navigation Jump to search
Added caption support for table style
(var -> lvar)
(Added caption support for table style)
Line 2: Line 2:
| 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>
Line 7: Line 9:
{{#while:
{{#while:
| {{{{{#lvar: i }} |}}}
| {{{{{#lvar: i }} |}}}
| <tr><td>{{Demo|sep=</td><td>|nocat=yes|tag=pre|style=margin:0px;border:0px;|{{trim|{{{ {{#lvar: i}} }}}}}}}</td></tr>
| <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 }} }}
{{#lvardef: i | {{#expr: {{#lvar: i }} + 1 }} }}
}}</table>
}}</table>
| list = {{#while:
| list = {{#while:
| {{{{{#lvar: i }} |}}}
| {{{{{#lvar: i }} |}}}
| <div class="bg3wiki-tooltip-box>{{#if:{{{caption {{#lvar: i}}|}}}|{{{caption {{#lvar: i}}|}}}<br><br>}}'''Markup'''{{Demo|sep='''Renders as<br>'''|nocat=yes|style=margin-top:0px;|tag=pre|{{trim|{{{ {{#lvar: i}} }}}}}}}</div>
| <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 }} }}
{{#lvardef: i | {{#expr: {{#lvar: i }} + 1 }} }}
}}
}}
Line 45: Line 50:
| <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
| &lt;nowiki>{{CharLink|Shadowheart}}</nowiki>
| caption 2 = DamageText demo
| &lt;nowiki>{{DamageText|2d4 + 1|Fire}}</nowiki>
| caption 3 = RarityItem demo
| &lt;nowiki>{{RarityItem|Hat of Fire Acuity}}</nowiki>
| caption 4 = SAI demo
| &lt;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 98:
}}
}}
</nowiki>
</nowiki>
| caption 2 = You can optionally add additional context or information to examples with {{c|caption <number>}} parameters.
| caption 2 = This example demonstrates many of the optional style parameters.
| &lt;nowiki>
| &lt;nowiki>
{{Quote fancy
{{Quote fancy
Line 86: Line 122:
}}
}}
</nowiki>
</nowiki>
| caption 2 = You can optionally add additional context or information to examples with {{c|caption <number>}} parameters.
| caption 2 = This example demonstrates many of the optional style parameters.
| <nowiki>
| <nowiki>
{{Quote fancy
{{Quote fancy

Navigation menu