Template:CodeBox/doc
From Gentoo Wiki
Jump to:navigation
Jump to:search
Note
This page is a template. It contains some standardized, often used text, which can be transcluded inside other pages. As this template is widely used in our wiki, it may be protected in which case only staff members can change it. Use the discussion page to propose enhancements or fixes, or to voice your opinion.
This page is a template. It contains some standardized, often used text, which can be transcluded inside other pages. As this template is widely used in our wiki, it may be protected in which case only staff members can change it. Use the discussion page to propose enhancements or fixes, or to voice your opinion.
Displays a block element containing code, optionally providing syntax highlighting. A list of recognized languages for syntax highlighting can be found here.
Important
File contents may contain the special characters
File contents may contain the special characters
|
or =
which are incompatible with MediaWiki's templating system. Substitute |
with {{!}}
and =
with {{=}}
for arguments to the 1=
parameter for correct template usage. If substitution is ignored, then formatting will not work correctly with this template.Parameters
Displays a block element containing code, optionally providing syntax highlighting
Parameter | Description | Type | Status | |
---|---|---|---|---|
Code | 1 | no description | Content | required |
Title | title | Additional title to display in the box header | Content | suggested |
Language | lang | Language of the contents, used for syntax highlighting
| String | suggested |
Usage
See the template's testcases:
No parameter | |
---|---|
Wiki code | {{CodeBox}}
|
Main version | {{{1}}}
|
Sandbox version | {{{1}}}
}} </noinclude> |
Parameters: 1=Some code. | |
---|---|
Wiki code | {{CodeBox|1=Some code.}}
|
Main version | Some code.
|
Sandbox version | Some code.
}} </noinclude> |
Parameters: title=CodeBox example with title, 1=And with some code. | |
---|---|
Wiki code | {{CodeBox|title=CodeBox example with title|1=And with some code.}}
|
Main version | And with some code.
|
Sandbox version | And with some code.
}} </noinclude> |
Parameters: title=CodeBox example with title, lang=bash, 1=#!/bin/bash echo "Hello, world!" | |
---|---|
Wiki code | {{CodeBox|title=CodeBox example with title|lang=bash|1=#!/bin/bash
echo "Hello, world!"
}}
|
Main version | #!/bin/bash
echo "Hello, world!"
|
Sandbox version | #!/bin/bash
echo "Hello, world!"
}} </noinclude> |