Template:Code/doc: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
{{Doc/subpage}}__NOTOC__
{{Doc/subpage}}__NOTOC__
This template will allow you to format text as a one-line code.
This template will allow you to format text as a one-line code.
== Usage ==
{{Template usage example|inline}}


== Parameters and Examples ==
== Parameters and Examples ==
Line 10: Line 13:
! {{int:preview}}
! {{int:preview}}
|-
|-
| align=center | {{Code|{{Param|preset}}}}
| style="text-align:center" | <code>{{param|1}}</code>
| Preset Template Styles. The following presets are available:
| Text.
:* {{Code|preset=0|Default}} – The default style is based on Markdown;
| style="background-color:#1f1f1f; font-family:monospace" | <pre style="margin:0">| Hello, World!
:* {{Code|preset=1|0}} – Clear version;
 
:* {{Code|preset=1|1}} – Desaturated version;
| 1 = Hello, World! </pre>
:* {{Code|preset=1|2}} – Outlined version;
| style="background-color:#262626" | {{Code|Hello, World!}}
:* {{Code|preset=1|3}} – A brighter outlined version.
| {{CodeBlock|&#123;&#123;Code&#124;{{Tint|color=comment|Hello, World!}}&#125;&#125;}} {{CodeBlock|&#123;&#123;Code&#124;{{Tint|color=yellow|preset}}&#61;{{Tint|color=green|0}}&#124;{{Tint|color=comment|Hello, World!}}&#125;&#125;}} {{CodeBlock|&#123;&#123;Code&#124;{{Tint|color=yellow|preset}}&#61;{{Tint|color=green|1}}&#124;{{Tint|color=comment|Hello, World!}}&#125;&#125;}} {{CodeBlock|&#123;&#123;Code&#124;{{Tint|color=yellow|preset}}&#61;{{Tint|color=green|2}}&#124;{{Tint|color=comment|Hello, World!}}&#125;&#125;}}{{CodeBlock|&#123;&#123;Code&#124;{{Tint|color=yellow|preset}}&#61;{{Tint|color=green|3}}&#124;{{Tint|color=comment|Hello, World!}}&#125;&#125;}}
| {{Capsule|margin=4px|{{Code|Hello, World!}}}} {{Capsule|margin=4px|{{Code|preset=0|Hello, World!}}}} {{Capsule|margin=4px|{{Code|preset=1|Hello, World!}}}} {{Capsule|margin=4px|{{Code|preset=2|Hello, World!}}}} {{Capsule|margin=4px|{{Code|preset=3|Hello, World!}}}}
|-
|-
| align=center | {{Code|{{Param|select}}}}
| rowspan="5" style="text-align:center" | <code>{{Param|preset}}</code>
| Text selection mode. Uses the {{Code|preset=1|user-select}} CSS property. Default value is {{Code|preset=1|unset}}.
| rowspan="5" | Preset Template Styles. The following presets are available:
| {{CodeBlock|&#123;&#123;Code&#124;{{Tint|color=yellow|select}}&#61;{{Tint|color=green|none}}&#124;{{Tint|color=comment|Hello, World!}}&#125;&#125;}} {{CodeBlock|&#123;&#123;Code&#124;{{Tint|color=yellow|select}}&#61;{{Tint|color=green|all}}&#124;{{Tint|color=comment|Hello, World!}}&#125;&#125;}}
:* {{code|preset=0|Default}} – The default style is based on Markdown;
| {{Capsule|margin=4px|{{Code|select=none|Hello, World!}}}} {{Capsule|margin=4px|{{Code|select=all|Hello, World!}}}}
:* {{code|preset=1|0}} – Clear version;
:* {{code|preset=1|1}} – Desaturated version;
:* {{code|preset=1|2}} – Outlined version;
:* {{code|preset=1|3}} – A brighter outlined version.
|-
|-
| align=center | {{Code|{{Param|style}}}}
| style="background-color:#1f1f1f; font-family:monospace" | <pre style="margin:0">| preset = 0</pre>
| style="background-color:#262626" | {{code|preset=0|Hello, World!}}
|-
| style="background-color:#1f1f1f; font-family:monospace" | <pre style="margin:0">| preset = 1</pre>
| style="background-color:#262626" | {{code|preset=1|Hello, World!}}
|-
| style="background-color:#1f1f1f; font-family:monospace" | <pre style="margin:0">| preset = 2</pre>
| style="background-color:#262626" | {{code|preset=2|Hello, World!}}
|-
| style="background-color:#1f1f1f; font-family:monospace" | <pre style="margin:0">| preset = 3</pre>
| style="background-color:#262626" | {{code|preset=3|Hello, World!}}
|-
| rowspan="3" style="text-align:center" | <code>{{Param|select}}</code>
| rowspan="3" | Text selection mode. Uses the {{code|preset=1|user-select}} CSS property. Default value is {{code|preset=1|unset}}.
|-
| style="background-color:#1f1f1f; font-family:monospace" | <pre style="margin:0">| select = none</pre>
| style="background-color:#262626" | {{code|select=none|Hello, World!}}
|-
| style="background-color:#1f1f1f; font-family:monospace" | <pre style="margin:0">| select = all</pre>
| style="background-color:#262626" | {{code|select=all|Hello, World!}}
|-
| style="text-align:center" | <code>{{Param|style}}</code>
| CSS styles.
| CSS styles.
| {{CodeBlock|&#123;&#123;Code&#124;{{Tint|color=yellow|style}}&#61;{{Tint|color=green|color:#EF9B9B}}&#124;{{Tint|color=comment|Hello, World!}}&#125;&#125;}}
| style="background-color:#1f1f1f; font-family:monospace" | <pre style="margin:0">| style = color:#EF9B9B</pre>
| {{Capsule|margin=4px|{{Code|style=color:#EF9B9B|Hello, World!}}}}
| style="background-color:#262626" | {{code|style=color:#EF9B9B|Hello, World!}}
|-
|-
| align=center | {{Code|{{Param|highlight}}}}
| style="text-align:center" | <code>{{Param|highlight}}</code>
| Adds syntax highlighting for the language specified. {{Bug|Condenses code into one line.}}
| Adds syntax highlighting for the language specified. {{Bug|Condenses code into one line.}}
| {{CodeBlock|margin=5px|<nowiki>{{Code|highlight=c|int main() {return 0;} }}</nowiki>}}
| style="background-color:#1f1f1f; font-family:monospace" | <pre style="margin:0">| highlight = c</pre>
| {{Capsule|margin=5px|{{Code|highlight=c|int main() {return 0;} }}}}
| style="background-color:#262626" | {{code|highlight=c|int main() {return 0;} }}
|-
|-
|}
|}

Revision as of 09:11, 7 October 2025

Edit-copy.png
This is a documentation subpage for Template:Code.
Don't forget to purge the contents of the base page upon creating or editing this subpage.

This template will allow you to format text as a one-line code.

Usage

This template is usually written in a single line. To use it, insert {{Code}} into the desired page and specify the parameters to the right of the template name in the following format: {{Code|parameter 1 = value|parameter 2 = value}}.

Parameters and Examples

Parameters Description Examples Preview
{{{1}}} Text.
| Hello, World!

| 1 = Hello, World! 
Hello, World!
{{{preset}}} Preset Template Styles. The following presets are available:
  • Default – The default style is based on Markdown;
  • 0 – Clear version;
  • 1 – Desaturated version;
  • 2 – Outlined version;
  • 3 – A brighter outlined version.
| preset = 0
Hello, World!
| preset = 1
Hello, World!
| preset = 2
Hello, World!
| preset = 3
Hello, World!
{{{select}}} Text selection mode. Uses the user-select CSS property. Default value is unset.
| select = none
Hello, World!
| select = all
Hello, World!
{{{style}}} CSS styles.
| style = color:#EF9B9B
Hello, World!
{{{highlight}}} Adds syntax highlighting for the language specified.
Icon-Bug.pngBug:Condenses code into one line.  [todo tested in ?]
| highlight = c
int main() {return 0;}