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
No edit summary
Line 13: Line 13:


Would result in this:
Would result in this:
{{code|{{ foo | bar }}}}
{{code|<nowiki>{{ foo | bar }}</nowiki>}}
And this code:
And this code:


Line 21: Line 21:


Would result in this:
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
{{code|Foo
bar
bar
   Hah!</pre></td></tr></table>
   Hah!}}
Similarly this code:
Similarly this code:


Line 30: Line 30:


Would result in this:
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!"
{{code|10 PRINT "Hello World!"
20 END</pre></td></tr></table>
20 END}}


Using it inline, like this:
Using it inline, like this:
Line 38: Line 38:


Would result in this:
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}}
{{co|grey|Foo}}{{code|Foo what? Huh? Huh!}}{{co|grey| bar}}


This as opposed to how <nowiki><pre></pre></nowiki> tags usually work:
This as opposed to how <nowiki><pre></pre></nowiki> tags usually work:

Revision as of 13:17, 28 November 2013

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:

  • {{ code | text }}

Example

This code:

{{ code | {{ foo | bar }}}}

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 :(