Difference between revisions of "Template:Code"

From EVE University Wiki
Jump to: navigation, search
m (Change white-space: to pre-wrap to avoid long texts, without line-breaks, running of the page.)
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<noinclude>
+
<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>
<div style="float:right; margin-left:1em; margin-bottom:1em;">__TOC__</div>
+
{{documentation}}
</noinclude><table style="border:1px dashed #555555; padding:5px; margin:5px;"><tr><td><pre style="padding:0px; margin:0px; border:0px;">{{{1}}}</pre></td></tr></table><noinclude>
+
</noinclude>
 
 
Just a little something to be able to use pre-formatted text within the confined of a code-like presentation without the box taking up the entire width of the page.
 
== Usage ==
 
It's a simple template, you just add the code or function name you wish to present as the second argument:
 
* <nowiki>{{ code | text }}</nowiki>
 
== Example ==
 
This code:
 
 
 
{{co|yellow|<nowiki>{{ code | {{ foo | bar }}}}</nowiki>}}
 
 
 
Would result in this:
 
<table style="border:1px dashed #555555; padding:5px; margin:5px;"><tr><td><pre style="padding:0px; margin:0px; border:0px;">{{ foo | bar }}</pre></td></tr></table>
 
And this code:
 
 
 
{{co|yellow|<nowiki>{{code|Foo</nowiki>}}<br>
 
{{co|yellow|bar}}<br>
 
{{co|yellow|&nbsp;&nbsp;Hah!<nowiki>}}</nowiki>}}
 
 
 
Would result in this:
 
<table style="border:1px dashed #555555; padding:5px; margin:5px;"><tr><td><pre style="padding:0px; margin:0px; border:0px;">Foo
 
bar
 
  Hah!</pre></td></tr></table>
 
Similarly this code:
 
 
 
{{co|yellow|<nowiki>{{code|10 PRINT "Hello World!"</nowiki>}}<br>
 
{{co|yellow|<nowiki>20 END}}</nowiki>}}<br>
 
 
 
Would result in this:
 
<table style="border:1px dashed #555555; padding:5px; margin:5px;"><tr><td><pre style="padding:0px; margin:0px; border:0px;">10 PRINT "Hello World!"
 
20 END</pre></td></tr></table>
 
 
 
Using it inline, like this:
 
 
 
{{co|yellow|foo <nowiki>{{code|Foo what? Huh? Huh!}}</nowiki> bar}}
 
 
 
Would result in this:
 
{{co|grey|Foo}}<table style="border:1px dashed #555555; padding:5px; margin:5px;"><tr><td><pre style="padding:0px; margin:0px; border:0px;">Foo what? Huh? Huh!</pre></td></tr></table>{{co|grey| bar}}
 
 
 
This as opposed to how <nowiki><pre></pre></nowiki> tags usually work:
 
<pre>Go ahead, use all the width :(</pre>
 
 
 
[[Category:Template]][[Category:Tools]]</noinclude>
 

Latest revision as of 17:18, 30 April 2022

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?)