Template:CodeBox: Difference between revisions
From HPC Wiki
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
<includeonly><div class="gw-box">{{PreBox|{{{1}}}|title=<strong>{{{title|}}}</strong>|label= | <includeonly><div class="gw-box">{{PreBox|{{{1}}}|title=<strong>{{{title|}}}</strong>|label=CODE|labelcolor=#204A87|lang={{{lang|text}}}}}</div></includeonly><noinclude>{{Documentation}}</noinclude> |
Revision as of 16:09, 15 December 2016
[edit]
Documentation
Note
This page is a template. It contains some standardized, often used text, which can be transcluded inside other pages.
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
Your contents may contain special characters (| or =) that break the MediaWiki templating system. You have these options to put the contents (in order from preferred to rather-not-use) if you need to escape these characters:
Your contents may contain special characters (| or =) that break the MediaWiki templating system. You have these options to put the contents (in order from preferred to rather-not-use) if you need to escape these characters:
{{CodeBox|1=contents}}
{{CodeBox|<nowiki>contents</nowiki>}}
{{CodeBox|<pre>contents</pre>}}
(Syntax highlighting is broken using this invocation!)
Parameters
Parameter name | Required? | Default value | Description |
---|---|---|---|
Anonymous parameter 1 |
Yes | (n/a) | Code |
title |
No | (n/a) | Additional title to display in the box header |
lang |
No | text |
Language of the contents, used for syntax highlighting |
Usage
See the template's testcases:
No parameter | |
---|---|
Wiki code | {{CodeBox}}
|
Main version | Template:XYZ |
Sandbox version | Template:XYZ/sandbox |
Parameters: 1=Some code. | |
---|---|
Wiki code | {{CodeBox|1=Some code.}}
|
Main version |
|
Sandbox version |
|
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 |
|
Sandbox version |
|
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 |
|
Sandbox version |
|
See also
Note
The above documentation is transcluded from Template:CodeBox/doc. (edit | history)
Editors can experiment in this template's sandbox (create) and testcases (edit) pages.
Please add categories and interwikis to the /doc subpage. Subpages of this template.
The above documentation is transcluded from Template:CodeBox/doc. (edit | history)
Editors can experiment in this template's sandbox (create) and testcases (edit) pages.
Please add categories and interwikis to the /doc subpage. Subpages of this template.