Difference between revisions of "Template:CodeBox"

From Mod My Classic Wiki
Jump to: navigation, search
(Created page with "<includeonly><div class="gw-box">{{PreBox|{{{1}}}|title=<strong>{{{title|}}}</strong>|label={{#msg:template-code|{{SUBPAGENAME}}}}|labelcolor=#204A87|lang={{{lang|}}}}}</div><...")
m (1 revision imported)
 
(No difference)

Latest revision as of 00:29, 5 January 2019

Documentation icon Template documentation[view] [edit] [history] [purge]

Template:Template

Displays a block element containing code, optionally providing syntax highlighting. A list of recognized languages for syntax highlighting can be found here.

{{#msg:template-important|CodeBox}}
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:
  1. {{CodeBox|1=contents}}
  2. {{CodeBox|<nowiki>contents</nowiki>}}
  3. {{CodeBox|<pre>contents</pre>}} (Syntax highlighting is broken using this invocation!)

Parameters[edit]

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[edit]

See the template's testcases:

No parameter
Wiki code {{CodeBox}}

Main version CodeBox}}
{{{1}}}
Sandbox version Template:CodeBox/sandbox
Parameters: 1=Some code.
Wiki code {{CodeBox|1=Some code.}}

Main version CodeBox}}
Some code.
Sandbox version CodeBox}}
Some code.
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 CodeBox}} CodeBox example with tile
And with some code.
Sandbox version CodeBox}} CodeBox example with title
Some code.
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 CodeBox}} CodeBox example with title
#!/bin/bash
echo "Hello, world!"
Sandbox version CodeBox}} CodeBox example with title
#!/bin/bash
echo "Hello, world!"

See also[edit]