Template:Demo
| This template, module and/or subpages are based on or ported over completely to BattleTechWiki, using the Creative Commons Licensed content from this page on Wikipedia (The original authors of this page are shown on here). |
| This template uses Lua: |
Usage[edit]
This template simply places template code in a <pre>...</pre> tag and then places the template below the pre tag.
{{demo
|br =
|demo_kill_categories =
|<nowiki>{{your template}}</nowiki>
}}
IMPORTANT: You must wrap include <nowiki>...</nowiki> tags around the source to be demonstrated (or use {{escape}}, which has a demo-escape example), like so:
{{demo|<nowiki>[template source]</nowiki>}}
- Failure to wrap
<nowiki>...</nowiki>tags around the source may cause the source to be executed before it reaches this template:✗ Fail<big style="color:#DF0A24; font-size:1.4em;">✗</big> '''Fail'''
Pre style[edit]
Set style= to add any CSS text to the <pre>...</pre> tag.
For example, {{demo|style=display:inline|<nowiki>{{done}}</nowiki>}}, would result in:
{{done}}
Line breaks[edit]
You can change the number of line breaks between the pre tag and the template by setting br= to a number. The default is 1.
{{demo|br=3|<nowiki>{{done}}</nowiki>}}
{{done}}
Alternative separator[edit]
You may also include an alternative separator by setting |br= to something other than a number and it will take the place of the br tags. For example, |br=<td> can make demo fit in a table:
{{done}}
| |
Category removal[edit]
For templates that add categories (e.g. {{Asbox}}), set |demo_kill_categories= (or |nocat=) to anything to prevent them from showing up in the output:
{{Asbox
| image = Østfold_våpen.svg
| pix = 30
| subject = [[Østfold]] location
| name = Template:Østfold-geo-stub
| category = Østfold geography stubs
| tempsort = *
}}
Module[edit]
If the template used is based on Lua, you can pass args directly to the demonstrated module by invoking Module:Demo like so: (this would reduce server stress)
Note: It will attempt to preserve line breaks for unnamed params, but such is impossible for named params since those are stripped of whitespace/order before being passed to the module. Also note, you should use |demo_br= instead of |br= (all args you don't want being passed should be prefixed with 'demo_' if not already)
Redirects[edit]
- {{Template Pre}}
- {{Tpre}}
- {{Doc pre}}
See also[edit]
- {{Demo-inline}}, for an inline version of this template
- {{Escape}} - which has an example of this template without nowiki tags
- {{Nowiki template demo}} which uses Module:Template test case
- {{Automarkup}} which uses Module:Automarkup
Other formatting templates[edit]
General-purpose formatting[edit]
| Text style ↓ | {{tlg}} options[note 1]to achieve text style |
Link style | |||||
|---|---|---|---|---|---|---|---|
| Linked | Unlinked | Linked with subst | Unlinked with subst | Linked including braces | Linked with alternative text | ||
{{tlg}} options[note 1]to achieve link style |
— | DEFAULT | nolink=yes
|
subst=yes
|
nolink=yes
|
braceinside=yes
|
alttext=Foo2=Foo
|
| normal | DEFAULT | {{tlg}} {{tl}} {{tlp|1|2|...}} {{Template:tlu}} |
{{tlf}} <template link> |
{{subst:tls}} {{subst:Template:tlsu}} |
{{subst:tlsf}} <template link> |
{{tn}} | {{tla}} |
code
|
code=yes
|
{{tl2}}
|
{{tlc}}<template link> {{tnull}}<template link>
|
{{subst:tlxs}}
|
{{subst:tlsc}}<template link> |
— | |
| monospace | plaincode=yes |
— | {{subst:tltss}} |
— | |||
| kbd | kbd=yes | ||||||
| bold | bold=yes
|
{{tlb}} | — | ||||
bold+code
|
bold=yes
|
{{tlxb}}
| |||||
italic+code
|
italic=yes
|
{{tlxi}}
| |||||
- ↑ a b c
{{tlg}}is the most general template, allowing any combination of text style and/or link style options. - ↑ a b c d e Prevents wrapping of text by placing it inside
<span class="nowrap">...</span>tags. - ↑ a b c Allows links to templates in any namespace.
- ↑
{{tlg|plaincode=yes}}uses<code style="border:none; background-color:transparent;">...</code>. - ↑ a b Displays monospaced font using
<span style="font-family:monospace;">...</span>.
Other formatting templates[edit]
| Code example | Effect | Notes |
|---|---|---|
{{Tj|Hatnote|Some text|selfref: yes|category: no|lang: fr}}
|
Supports colors, placeholder texts, named and unnamed parameters | |
<syntaxhighlight lang="wikitext">
{{Hatnote
| Some text
| selfref = yes
| category = no
| lang = fr
}}
</syntaxhighlight>
|
{{Hatnote
| Some text
| selfref = yes
| category = no
| lang = fr
}}
|
Same as above |
{{Tji|Hatnote|Some text|selfref: yes|category: no|lang: fr}}
|
{{Hatnote |
Supports colors, placeholder texts, named and unnamed parameters |
|
{{Hatnote|Some text|selfref=yes|category=no|lang=fr}}
|
Same as above |
{{tln|Hatnote}}
|
Template:Hatnote | Produces a normal link to the template |
{{elc|Template:Hatnote}}{{elc|Template:Hatnote|Hatnote}}
|
[[Template:Hatnote]][[Template:Hatnote|Hatnote]] |
Formats wikilink, with optional piped link text and blended suffix |
{{ml|Example|hello}}
|
{{#invoke:Example|hello}} | Counterpart to {{tl}} for linking to Lua modules |
{{mfl|Example|hello}}
|
{{#invoke:Example|hello}} | Similar to {{ml}}, but expects the function to be documented and creates a link to the corresponding section |
{{mlx|Example|hello}}
|
{{#invoke:Example|hello}} |
Counterpart to {{tlx}} for linking to Lua modules |
{{ml-lua|Module:Example}}
|
require('Module:Example') |
Link to Lua modules and built-in libraries, showing Lua code. |
{{para|title|<var>book title</var>}}
|
title=book title | Formats template parameters for display, with or without values |
{{sclx|mos}}
|
[[BTW:MOS]] |
Takes a shortcut suffix in project namespace and displays it with brackets and the BTW: alias in a <code>...</code> tag.
|
{{tag|ref}}{{xtag|templatedata}}
|
<ref>...</ref><templatedata> |
Formats [X]HTML tags; can add content, choose opening, closing, or self-closing |
{{dtl|Ping project}}
|
Wikidata:Ping project]}} | Wikidata counterpart to {{tl}} |
{{pf|if}}{{pf|if|{{{1}}}|true|false}}
|
{{#if}} {{#if:{{{1}}}|true|false}} |
Parser function equivalent to {{tl}} |
{{magic word|uc:}}
|
{{uc:}} | Magic word links |
With utility links[edit]
| Code example | Effect |
|---|---|
{{lt|Hatnote}}
|
Template:Hatnote (edit | talk | history | links | watch | logs) |
{{lts|Hatnote}}
|
Template:Hatnote(edit talk links history) |
{{tfd links|Hatnote}}
|
Template:Hatnote (talk · history · transclusions · logs · subpages) |
{{tetl|Hatnote}}
|
{{Hatnote}} |
{{tsetl|Hatnote}}
|
{{subst:Hatnote}} |
{{ti|Hatnote}}
|
Template:Hatnote (talk · links · edit) |
{{tic|Hatnote}}
|
Template:Hatnote (talk links edit) |
{{tim|Hatnote}}
|
mw:Template:Hatnote (backlinks edit) |
{{tiw|Hatnote}}
|
Template:Hatnote (backlinks edit) |
{{tlt|Hatnote}}
|
{{Hatnote}} (talk) |
{{ttl|Hatnote}}
|
{{Hatnote}} (t/l) |
{{twlh|Hatnote}}
|
Template:Hatnote (links, talk) |
No description.
| Parameter | Description | Type | Status | |
|---|---|---|---|---|
| Content | 1 | must be wrapped in <nowiki> | Unknown | optional |
| br | br | Number of line breaks, or wikitext to fill in as the linebreak | Unknown | optional |
| demo_kill_categories | demo_kill_categories nocat | no description | Boolean | optional |
| result_arg | result_arg | no description | Unknown | optional |
| <pre> style | style | no description | Unknown | optional |

