Jump to content

Template:Code

From NixOS Wiki

Template Documentation [edit source| uses| help]

Use this template to show code that has syntax highlighting.

Some code with [[:Wikipedia:Syntax highlighting|syntax highlighting]]

Usage

Include this template, specifying the language and code that should be displayed:

{{code|lang=mediawiki|Some code with [[:Wikipedia:Syntax highlighting|syntax highlighting]]}}

You can disable the "Copy" button by setting the parameter to 'no':

{{code|lang=mediawiki|copy=no|Some code}}

This would result in:

Some code

You can disable line numbers by setting the line parameter to 'no':

{{code|lang=mediawiki|line=no|Some code}}

This would result in:

Some code

Template data

Display a block of code

Template parameters[Edit template data]

ParameterDescriptionTypeStatus
Programming languagelang

The programming language used in the block of code

Stringsuggested
Show line numbers?line

By default, the block of code will show line numbers. You can disable this by setting this value to 'no'.

Suggested values
no
Booleanoptional
Show copy button?copy

By default, a 'Copy' button will be shown in the top right corner; you can override this setting by setting its value to 'no'.

Suggested values
no
Booleanoptional
Highlight lineshighlight

You can supply a comma-delimited list of lines to highlight. E.g.: 1,7,13-15

Stringoptional
Content1

The content to be shown in the block of code

Stringrequired