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/doc: Difference between revisions

Template page
Djavin novienta (talk | contribs)
Created page with "<noinclude>{{main|Template:Code}}</noinclude> == Usage == This template allows the presentation of pre-formatted text within the confines of a code-like presentation without t..."
 
Arin Mara (talk | contribs)
mNo edit summary
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
<noinclude>{{main|Template:Code}}</noinclude>
<noinclude>{{main|Template:Code}}</noinclude>
== Usage ==
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.
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><nowiki>{{ code | text }}</nowiki></code>
; Example
: This code:
: <code><nowiki>{{ code | <nowiki> {{ foo | bar }} </nowiki></nowiki><nowiki> }}</nowiki></code>


Simply add the code or function name you wish to present as the second argument:
: Would result in this:
* <nowiki>{{ code | text }}</nowiki>
: {{code|<nowiki>{{ foo | bar }}</nowiki>}}
== Example ==
This code:


{{co|yellow|<nowiki>{{ code | <nowiki> {{ foo | bar }} </nowiki></nowiki><nowiki> }}</nowiki>}}
: And this code:
: <code><nowiki>{{code|Foo</nowiki></code>
: <code>bar</code>
: <code>&nbsp;&nbsp;Hah!<nowiki>}}</nowiki></code>


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


{{co|yellow|<nowiki>{{code|Foo</nowiki>}}<br>
: Similarly this code:
{{co|yellow|bar}}<br>
: <code><nowiki>{{code|10 PRINT "Hello World!"</nowiki><br><nowiki>
{{co|yellow|&nbsp;&nbsp;Hah!<nowiki>}}</nowiki>}}
20 END}}</nowiki></code>


Would result in this:
: Would result in this:
{{code|Foo
: {{code|10 PRINT "Hello World!"<br>20 END}}
bar
  Hah!}}
Similarly this code:


{{co|yellow|<nowiki>{{code|10 PRINT "Hello World!"</nowiki>}}<br>
: Using it inline, like this:
{{co|yellow|<nowiki>20 END}}</nowiki>}}<br>
: <code>foo <nowiki>{{code|Foo what? Huh? Huh!}}</nowiki> bar</code>


Would result in this:
: Would result in this:
{{code|10 PRINT "Hello World!"
: {{co|grey|Foo}}{{code|Foo what? Huh? Huh!}}{{co|grey| bar}}
20 END}}


Using it inline, like this:
: This as opposed to how <nowiki><pre></pre></nowiki> tags usually work:
 
: <pre>Go ahead, use all the width :(</pre>
{{co|yellow|foo <nowiki>{{code|Foo what? Huh? Huh!}}</nowiki> bar}}
<includeonly>[[Category:Formatting templates]]</includeonly>
 
Would result in this:
{{co|grey|Foo}}{{code|Foo what? Huh? Huh!}}{{co|grey| bar}}
 
This as opposed to how <nowiki><pre></pre></nowiki> tags usually work:
<pre>Go ahead, use all the width :(</pre>
 
<includeonly>[[Category:Template]]</includeonly>
<noinclude>[[Category:Template documentation]]</noinclude>
<noinclude>[[Category:Template documentation]]</noinclude>