Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.
Template documentation (for the above template, sometimes hidden or invisible) [view] [edit] [history] [refresh]

Template:Documentation header Template:Lua Template:Shortcut This template is a short and quick way to use Template:Xtag tag. It accepts multiple arguments, which produce multiple Template:Xtag tags separated by single space characters when used.

For long text or nested HTML tags/templates, it's preferable to use Template:Xtag directly instead of using this template. Additionally, each call of a template may slow down the page load, and if more, may hit some template limits, compared to Template:Xtag, which is not affected by this side-effect.

Usage

Parameters

Code template parameters
Parameter Behavior Accepted values Default
Anonymous parameters, i.e. parameters that don't have names, Template:P, Template:P, etc. These are the text that code will display as inline <code> elements. One <code> element will be used to wrap each of the anonymous parameters. Any text. None
Template:Cd The delimiter to use between the <code> elements. Template:Cd or any other text. Template:Cd have a special behavior where the delimiter is different at the end, and Template:Cd adds a space after the comma, but all other deimiters are simply placed between the <code> elements. Template:Cd (a single space)
Template:Cd If specified, long words in the <code> element will break into multiple lines. This might be required if you are dealing with URLs (see below). Template:Cd or any other non-empty string. (boolean) False

Escape characters

Keep in mind pipes and equals signs are used to specifiy parameters in templates. If you want the text "number of cats = number of mice * 3 * multiplier" to be formatted propoerly, you must escape the Template:Cd. Template:Cd gives an error because the equal sign if interpreted as assigning an empty string to the paramer whose name is an empty string.

Magic words

There are many ways to "escape" text on this wiki. First, we have magic words for the equals sign and pipe. And we can use the non-breaking space HTML entity for spaces.

Magic words
Wikitext Result Result in Code
Template:Cd Template:Cd
Template:Cd = Template:Cd
Template:Cd = Template:Cd

You might also need to escape double curly braces, {{like these}}, and many other forms of formatting on this wiki. This can be done using Template:Cd, or by putting Template:Cd between the braces. Non-breaking space (Template:Cd) works more often than Template:Cd element does, so I suggest you use Template:Cd.

Use the Template:P parameter (aliases Template:P or Template:P) to change the separator between each string. Set this value to the name in words of the delimiter, such as "and", "br", "or-list", "none", etc. When using a list delimiter, use Template:P to change the indentation (defaults to Template:Cd).

HTML entities

If you want to include spaces at the start of end of a <code> element, you need to either escape it with Template:Cd or use Template:Cd.

If you want to use <angle brackets>, <like this>, you might need to use more HTML entities. Usually, you won't need to do this, inless you are describing how to use HTML elements or HTML entities on the page where you're using this template.

Finally, in some rare instances, you will need to use the legendary Template:Cd, or even the mythical Template:Cd.

Caption text
Name HTML Result Result in Code
Non-breaking space Template:Cd   Template:Cd
Less than Template:Cd < Template:Cd
Greater than Template:Cd > Template:Cd
Ampersand Template:Cd & Template:Cd

Examples

  1. {{code|text}} – Template:Code
  2. {{code|1|2|3|4|5}} – Template:Code
  3. Formatted code
    1. {{code|''fancy text''}} – Template:Code
    2. {{code|'''emphasized text'''}} – Template:Code
    3. {{code|link to [[Zombie]]}} – Template:Code
    4. {{code|[https://imgur.com/]}} – Template:Code
  4. Comma delimiter
    1. {{code|1|2|3|4|5|d=,}} – Template:Code
    2. {{code|1|2|3|4|5|delim=,}} – Template:Code
    3. {{code|1|2|3|4|5|delimiter=,}} – Template:Code
  5. And delimiter
    1. {{code|1|2|3|4|5|d=and}} – Template:Code
    2. {{code|1|2|3|4|5|delim=and}} – Template:Code
    3. {{code|1|2|3|4|5|delimiter=and}} – Template:Code
  6. Or delimiter
    1. {{code|1|2|3|4|5|d=or}} – Template:Code
    2. {{code|1|2|3|4|5|delim=or}} – Template:Code
    3. {{code|1|2|3|4|5|delimiter=or}} – Template:Code
  7. Escape character usage
    1. {{code|<nowiki>something=one|two|three</nowiki>}} – Template:Code
    2. {{code|something{{=}}one{{!}}two{{!}}three}} – Template:Code
    3. {{code|<nowiki> </nowiki>}} – Template:Code
    4. {{code|&nbsp;}} – Template:Code

Word Breaking

Breaking example 1
Header text A Header text B Header text C Header text D Header text E
Some text Template:Cd More text More text More text, extended to make my point.
Template:Cd Some text More text More text More text, extended to make my point.
Yet more text. Yet more text. Yet more text. Yet more text. Yet more text.

However, if we have an extremely long URL (this example is not actually in the game), like Template:Cd, it will not break when used in a table and will end up making its column far too wide.

I have collapsed this table for your convenience. Good luck finding the collapse button after expanding it!

Breaking example 2
Header text A Header text B Header text C Header text D Header text E
Some text Template:Cd More text More text More text, extended to make my point.
Template:Cd Some text More text More text More text, extended to make my point.
Yet more text. Yet more text. Yet more text. Yet more text. Yet more text.

As you can see, having our words break would be nice here. The easiest way to do this to use the Template:Cd parameter. It allows the line to break anywhere it needs to, even in the middle of a word. The table below shows what this does

Breaking example 3
Wiki text Code result Header text C Header text D Header text E
Template:Cd Template:Cd More text More text More text, extended to make my point.
Template:Cd Template:Cd More text More text More text, extended to make my point.
Yet more text. Yet more text. Yet more text. Yet more text. Yet more text.

See also

cs:Šablona:Code es:Plantilla:Código fr:Modèle:Code ja:Template:Code lzh:模板:Code nl:Sjabloon:Code pl:Szablon:Code pt:Predefinição:Código ru:Шаблон:Code th:แม่แบบ:Code uk:Шаблон:Code

zh:模板:Code
The above text is transcluded from Template:MC/Code/doc; you can change it or view its history.
If you're done making changes, please refresh the text.
Please add categories and interwikis to Template:MC/Code/doc. (View all subpages of this page.)