Template:Demo/doc

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:
    Template:Fail

    Template: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}}


 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}}






 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}}
 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 = *
}}

produces:


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]

See also[edit]

Other formatting templates[edit]

General-purpose formatting[edit]

Comparison of template-linking templates according to the styles of generated text and link produced
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|subst=yes braceinside=yes alttext=Foo
2=Foo
normal DEFAULT {{tlg}}[note 1]
{{tl}}
{{tlp|1|2|...}}[note 2]
{{Template:tlu}}[note 3]
{{tlf}}[note 2]
<template link>
{{subst:tls}}
{{subst:Template:tlsu}}[note 3]
{{tlsf}}[note 2]
<template link>
{{tn}} {{tla}}
code code=yes {{tl2}}


{{tlx}}
{{Template:tlxu}}[note 3]

{{tlc}}[note 2]
<template link>
{{tnull}}<template link>
{{subst:tlxs}} {{subst:tlsc}}[note 2]
<template link>
monospace plaincode=yes[note 4] {{subst:tltss}}[note 5]
kbd kbd=yes[note 5]
bold bold=yes {{tlb}}
bold+code bold=yes|code=yes {{tlxb}}
italic+code italic=yes|code=yes {{tlxi}}
  1. 1.0 1.1 1.2 {{tlg}} is the most general template, allowing any combination of text style and/or link style options.
  2. 2.0 2.1 2.2 2.3 2.4 Prevents wrapping of text by placing it inside <span class="nowrap">...</span> tags.
  3. 3.0 3.1 3.2 Allows links to templates in any namespace.
  4. {{tlg|plaincode=yes}} uses <code style="border:none; background-color:transparent;">...</code>.
  5. 5.0 5.1 Displays monospaced font using <span style="font-family:monospace;">...</span>.

Other formatting templates[edit]

Templates producing specialised formatting effects for given templates, modules or parameters
Code example Effect Notes
{{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
{{mlx|Example|hello}} {{#invoke:Example|hello}} Counterpart to {{tlx}} for linking to Lua modules
{{ml-lua|Module:Example|hello}} 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|Cleanup}} [[BTW:CLEANUP]] Takes a shortcut suffix in project namespace and displays it with brackets and the WP: 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
{{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]

Templates producing utility links for a given template (Hatnote used here as example)
Code example Effect
{{lt|Hatnote}} Template:Hatnote (edit | talk | history | links | watch | logs)
{{lts|Hatnote}} Template:Hatnote (Edit Discussion links Page history)
{{tfd links|Hatnote}} Template:Hatnote (talk · history · transclusions · logs · subpages)
{{tetl|Hatnote}} {{Hatnote}}
links talk edit
{{tsetl|Hatnote}} {{subst:Hatnote}}
 links talk edit
{{ti|Hatnote}} Template:Hatnote (talk · links · edit)
{{tic|Hatnote}} Template:Hatnote (talk links edit)
{{tiw|Hatnote}} Template:Hatnote (backlinks edit)
{{tlt|Hatnote}} {{Hatnote}} (talk)
{{ttl|Hatnote}} {{Hatnote}} (t/l)
{{twlh|Hatnote}} Template:Hatnote (links, talk)


No description.

Template parameters

ParameterDescriptionTypeStatus
Content1

must be wrapped in <nowiki>

Unknownoptional
Br br

Number of line breaks, or wikitext to fill in as the linebreak

Unknownoptional
Demo_kill_categoriesdemo_kill_categories nocat

no description

Booleanoptional
Result_argresult_arg

no description

Unknownoptional
<pre> stylestyle

no description

Unknownoptional