Template:Code/Doc: Difference between revisions

DoggoBit (talk | contribs)
Created page with "Use this template to show code that has syntax highlighting. {{code|lang=mediawiki|Some code with syntax highlighting}} === Usage === Include this template, specifying the language and code that should be displayed: {{code|lang=mediawiki|<nowiki>{{code|lang=mediawiki|Some code with syntax highlighting}}</nowiki>}}"
 
DoggoBit (talk | contribs)
m Template data: also document copy
 
(3 intermediate revisions by the same user not shown)
Line 7: Line 7:
Include this template, specifying the language and code that should be displayed:
Include this template, specifying the language and code that should be displayed:


{{code|lang=mediawiki|<nowiki>{{code|lang=mediawiki|Some code with [[:Wikipedia:Syntax highlighting|syntax highlighting]]}}</nowiki>}}
{{code|lang=mediawiki|line=no|<nowiki>{{code|lang=mediawiki|Some code with [[:Wikipedia:Syntax highlighting|syntax highlighting]]}}</nowiki>}}
 
You can disable the ''"Copy"'' button by setting the parameter to 'no':
 
{{code|lang=mediawiki|line=no|<nowiki>{{code|lang=mediawiki|copy=no|Some code}}</nowiki>}}
 
This would result in:
 
{{code|lang=mediawiki|copy=no|Some code}}
 
You can disable line numbers by setting the <code>line</code> parameter to 'no':
 
{{code|lang=mediawiki|line=no|<nowiki>{{code|lang=mediawiki|line=no|Some code}}</nowiki>}}
 
This would result in:
 
{{code|lang=mediawiki|line=no|Some code}}
 
=== Template data ===
 
<templatedata>
{
  "description": "Display a block of code",
  "params": {
    "lang": {
      "label": "Programming language",
      "description": "The programming language used in the block of code",
      "type": "string",
      "suggested": true
    },
    "line": {
      "label": "Show line numbers?",
      "description": "By default, the block of code will show line numbers. You can disable this by setting this value to 'no'.",
      "type": "boolean",
      "suggestedvalues": [
        "no"
      ]
    },
    "copy": {
      "label": "Show copy button?",
      "description": "By default, a 'Copy' button will be shown in the top right corner; you can override this setting by setting its value to 'no'.",
      "type": "boolean",
      "suggestedvalues": [
        "no"
      ]
    },
    "highlight": {
      "label": "Highlight lines",
      "description": "You can supply a comma-delimited list of lines to highlight. E.g.: 1,7,13-15",
      "type": "string"
    },
    "1": {
      "label": "Content",
      "description": "The content to be shown in the block of code",
      "type": "string",
      "required": true
    }
  }
}
</templatedata>