Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Template:Code: Difference between revisions

Template page
m Change white-space: to pre-wrap to avoid long texts, without line-breaks, running of the page.
m Undo source format. Had unwanted effects.
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
<includeonly><table style="margin:5px; border:1px dashed #555555; padding:5px;"><tr><td style="white-space: pre-wrap; font-family: monospace,Courier; color: white;">{{{1|No content.}}}</td></tr></table></includeonly><noinclude>
<includeonly><table style="margin:5px; border:1px dashed #555555; padding:5px; background-color: SlateGray;"><tr><td style="white-space: pre-wrap; font-family: monospace,Courier; color: white;">{{{1|No content.}}}</td></tr></table></includeonly><noinclude>
{{documentation}}
{{documentation}}
</noinclude>
</noinclude>

Latest revision as of 12:07, 14 May 2025

Template documentation (for the above template, sometimes hidden or invisible)

This template allows the presentation of pre-formatted text within the confines of a code-like presentation without the box taking up the entire width of the page.

Usage
Simply add the code or function name you wish to present as the second argument:
{{ code | text }}
Example
This code:
{{ code | <nowiki> {{ foo | bar }} </nowiki> }}
Would result in this:
{{ foo | bar }}
And this code:
{{code|Foo
bar
  Hah!}}
Would result in this:
Foo
bar
Hah!
Similarly this code:
{{code|10 PRINT "Hello World!"
20 END}}
Would result in this:
10 PRINT "Hello World!"
20 END
Using it inline, like this:
foo {{code|Foo what? Huh? Huh!}} bar
Would result in this:
Foo
Foo what? Huh? Huh!
bar
This as opposed to how <pre></pre> tags usually work:
Go ahead, use all the width :(
Visit Template:Code/doc to edit this text! (How does this work?) (Refresh this text - why?)