Template:code

Revision as of 23:37, 5 August 2023 by Maria (talk | contribs) (Created page with "{{#tag:syntaxhighlight<!-- -->|{{{|{{{2}}}}}}<!-- -->|lang={{#switch:{{{1}}}<!-- -->|js=javascript<!-- -->|py=python<!-- -->|#default={{#ifeq:{{{1|}}}||text|{{{1}}}}}<!-- -->}}<!-- -->|style={{{style|}}}<!-- -->|inline=inline}}<noinclude>{{documentation}}</noinclude>")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

{{{2}}}

TemplateDocumentation.svg Template documentation [view] [edit] [purge]

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 w:Template:code, but the argument order is opposite.

Example

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

See also