Template:CodeBlock/doc: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
Line 11: | Line 11: | ||
! style=width:27% | Preview | ! style=width:27% | Preview | ||
|- | |- | ||
| align=center | {{Code|{{ | | align=center | {{Code|{{Param|1}}}} | ||
| Your code.<br>It is recommended to wrap the template content with the {{Code|select=1|<nowiki>}} tag. | | Your code.<br>It is recommended to wrap the template content with the {{Code|select=1|<nowiki>}} tag. | ||
| {{CodeBlock|margin=5px|<nowiki>{{CodeBlock|Hello, World!}}</nowiki>}} | | {{CodeBlock|margin=5px|<nowiki>{{CodeBlock|Hello, World!}}</nowiki>}} | ||
| {{Capsule|margin=5px|{{CodeBlock|margin=0|Hello, World!}}}} | | {{Capsule|margin=5px|{{CodeBlock|margin=0|Hello, World!}}}} | ||
|- | |- | ||
| align=center | {{Code|{{ | | align=center | {{Code|{{Param|margin}}}} | ||
| Controls margins. | | Controls margins. | ||
| {{CodeBlock|margin=5px|<nowiki>{{CodeBlock|margin=0 20px 0 20px|Hello, World!}}</nowiki>}} | | {{CodeBlock|margin=5px|<nowiki>{{CodeBlock|margin=0 20px 0 20px|Hello, World!}}</nowiki>}} | ||
| {{Capsule|margin=5px|{{CodeBlock|margin=0 20px 0 20px|Hello, World!}}}} | | {{Capsule|margin=5px|{{CodeBlock|margin=0 20px 0 20px|Hello, World!}}}} | ||
|- | |- | ||
| align=center | {{Code|{{ | | align=center | {{Code|{{Param|style}}}} | ||
| The style of the template. The following styles are available: | | The style of the template. The following styles are available: | ||
:* {{Code|1}} - Outlined version; | :* {{Code|1}} - Outlined version; | ||
Line 28: | Line 28: | ||
| {{Capsule|margin=5px|{{CodeBlock|style=1|margin=0|Hello, World!}}}} | | {{Capsule|margin=5px|{{CodeBlock|style=1|margin=0|Hello, World!}}}} | ||
|- | |- | ||
| align=center | {{Code|{{ | | align=center | {{Code|{{Param|limited}}}} | ||
| Limits the block height to 400 pixels and enables scrolling. | | Limits the block height to 400 pixels and enables scrolling. | ||
| {{CodeBlock|margin=5px|<nowiki>{{CodeBlock|limited=1|1. Hello World | | {{CodeBlock|margin=5px|<nowiki>{{CodeBlock|limited=1|1. Hello World | ||
Line 36: | Line 36: | ||
| align=center | See below | | align=center | See below | ||
|- | |- | ||
| align=center | {{Code|{{ | | align=center | {{Code|{{Param|height}}}} | ||
| Controls the height of the block.<br>Does not work without {{param|limited}}.<br>The maximum height is 400 pixels. | | Controls the height of the block.<br>Does not work without {{param|limited}}.<br>The maximum height is 400 pixels. | ||
| {{CodeBlock|margin=5px|<nowiki>{{CodeBlock|limited=1|height=34px|1. Hello World | | {{CodeBlock|margin=5px|<nowiki>{{CodeBlock|limited=1|height=34px|1. Hello World | ||
Line 43: | Line 43: | ||
4. Hello World}}</nowiki>}} | 4. Hello World}}</nowiki>}} | ||
| {{Capsule|margin=5px|{{CodeBlock|limited=1|height=34px|margin=0|<nowiki>1. Hello World | | {{Capsule|margin=5px|{{CodeBlock|limited=1|height=34px|margin=0|<nowiki>1. Hello World | ||
2. Hello World | |||
3. Hello World | |||
4. Hello World</nowiki>}}}} | |||
|- | |||
| align=center | {{Code|{{Param|lines}}}} | |||
| ''Manual:'' Numbered lines. | |||
| {{CodeBlock|margin=5px|<nowiki>{{CodeBlock|lines=4|1. Hello World | |||
2. Hello World | |||
3. Hello World | |||
4. Hello World}}</nowiki>}} | |||
| {{Capsule|margin=5px|{{CodeBlock|lines=4|margin=0|<nowiki>1. Hello World | |||
2. Hello World | 2. Hello World | ||
3. Hello World | 3. Hello World | ||
Line 57: | Line 68: | ||
! style=width:27% | Preview | ! style=width:27% | Preview | ||
|- | |- | ||
| align=center | {{Code|{{ | | align=center | {{Code|{{Param|src}}}} | ||
| The source of your code. | | The source of your code. | ||
| {{CodeBlock|margin=5px|<nowiki>{{CodeBlock|src=light.rad|forcetextureshadow props_foliage/urban_tree01.mdl}}</nowiki>}} | | {{CodeBlock|margin=5px|<nowiki>{{CodeBlock|src=light.rad|forcetextureshadow props_foliage/urban_tree01.mdl}}</nowiki>}} | ||
| {{Capsule|margin=5px|{{CodeBlock|src=light.rad|margin=0|forcetextureshadow props_foliage/urban_tree01.mdl}}}} | | {{Capsule|margin=5px|{{CodeBlock|src=light.rad|margin=0|forcetextureshadow props_foliage/urban_tree01.mdl}}}} | ||
|- | |- | ||
| align=center | {{Code|{{ | | align=center | {{Code|{{Param|lang}}}} | ||
|The name of the language displayed on the right side of the header. | |The name of the language displayed on the right side of the header. | ||
| {{CodeBlock|margin=5px|<nowiki>{{CodeBlock|lang=cs|<nowiki>using System; | | {{CodeBlock|margin=5px|<nowiki>{{CodeBlock|lang=cs|<nowiki>using System; | ||
Line 90: | Line 101: | ||
|} | |} | ||
<includeonly> | <includeonly>[[Category:Templates]] [[Category:Formatting templates]]</includeonly> | ||
[[Category:Templates]][[Category:Formatting templates]] | |||
Revision as of 07:00, 17 February 2023

This is a documentation subpage for Template:CodeBlock.
Don't forget to purge the contents of the base page upon creating or editing this subpage.
Don't forget to purge the contents of the base page upon creating or editing this subpage.
This template formats the text as a block of code.
Parameters and Examples
Main
The main parameters are described below.
Name | Description | Example | Preview |
---|---|---|---|
{{{1}}}
|
Your code. It is recommended to wrap the template content with the <nowiki> tag.
|
||
{{{margin}}}
|
Controls margins. | ||
{{{style}}}
|
The style of the template. The following styles are available:
|
||
{{{limited}}}
|
Limits the block height to 400 pixels and enables scrolling. | See below | |
{{{height}}}
|
Controls the height of the block. Does not work without {{{limited}}}. The maximum height is 400 pixels. |
||
{{{lines}}}
|
Manual: Numbered lines. |
Header
The parameters for adding a header with the code source and the name of the programming language are described below. Template:ModernNote
Name | Description | Example | Preview |
---|---|---|---|
{{{src}}}
|
The source of your code. | ||
{{{lang}}}
|
The name of the language displayed on the right side of the header. |