Template:Code/documentation: Difference between revisions

From The Languages of David J. Peterson
Jump to navigation Jump to search
m (Text replacement - "(\[\[)w:(.+?\|.+?\]\])" to "\1Wikipedia:\2")
m (Text replacement - "(\[\[)w:([^\|\]\[]+?)(\]\])" to "\1Wikipedia:\2|\2\3")
 
Line 2: Line 2:
This is a convenience template, which formats a short inline snippet of code with syntax highlighting of a given language. The language is specified as the first positional parameter (as understood by the {{wikitag|syntaxhighlight}} tag, with "<code>js</code>" being a shorthand for <code>[[Wikipedia:JavaScript|javascript]]</code> and "<code>py</code>" for <code>[[w:Python (programming language)|python]]</code>), while the second is the snippet to format. Alternatively, you can specify the snippet as a named parameter with an empty name ({{para||2==...}}) in case the code contains an equal sign.
This is a convenience template, which formats a short inline snippet of code with syntax highlighting of a given language. The language is specified as the first positional parameter (as understood by the {{wikitag|syntaxhighlight}} tag, with "<code>js</code>" being a shorthand for <code>[[Wikipedia:JavaScript|javascript]]</code> and "<code>py</code>" for <code>[[w:Python (programming language)|python]]</code>), while the second is the snippet to format. Alternatively, you can specify the snippet as a named parameter with an empty name ({{para||2==...}}) in case the code contains an equal sign.


It is similar to Wikipedia's [[w:Template:code]], but the argument order is opposite.
It is similar to Wikipedia's [[Wikipedia:Template:code|Template:code]], but the argument order is opposite.


== Example ==
== Example ==

Latest revision as of 06:00, 30 August 2024

Documentation for Template:Code. [edit]
This page contains usage information, categories, interwiki links and other content describing the template.

This is a convenience template, which formats a short inline snippet of code with syntax highlighting of a given language. The language is specified as the first positional parameter (as understood by the <syntaxhighlight> tag, with "js" being a shorthand for javascript and "py" for python), while the second is the snippet to format. Alternatively, you can specify the snippet as a named parameter with an empty name (|=...) in case the code contains an equal sign.

It is similar to Wikipedia's Template:code, but the argument order is opposite.

Example

{{code|js|=(65535).toString(16) === 'ffff'}} renders as (65535).toString(16) === 'ffff'.

See also