Template:Code: Difference between revisions From Online Manual

Jump to: navigation, search
(add class code -- for better styling in the future)
(Styling the div now to be done in the skin or in Common.css)
Line 1: Line 1:
<!-- You cannot use pre as a temporary standin for code because you cannot use it with parameters! -->
<!-- You cannot use pre as a temporary standin for code because you cannot use it with parameters! -->
<div class="code" style="border-top: solid gray 1px; border-bottom: solid gray 1px;">
<div class="code" >
{{Use tag
{{Use tag
|tag=pre
|tag=pre

Revision as of 19:26, 22 March 2011


[edit] [purge] Template documentation

This template is used to style blocks of code. It adds a horizontal line above and below the code block.

{{code
|1=&nbsp;   <td align="right" class="catbg">
        <img src="', $settings['images_url'], '/smflogo.gif" style="margin: 2px;" alt="" />
    </td>}}
    <td align="right" class="catbg">
        <img src="', $settings['images_url'], '/smflogo.gif" style="margin: 2px;" alt="" />
    </td>

The <code> tag should be used, instead, for inline code fragments, but will not do a good job with multi-line fragments in which some lines are indented and some are not.

Here are three simple rules to follow that will help you show your code the way you want it.

  1. If your code fragment begins with whitespace (space or tabs), stop the wiki-parser from "eating" those spaces in one of these ways
    • Enclose your code in <nowiki> tags
    • Start your code with a non-whitespace character (add a blank comment line, for example)
    • Start your code with a &nbsp; character
  2. | in your code will confuse the wiki parser terribly. Use {{!}} or &#124; instead. See Meta:Help:Template for more on how the {{|}} is used within wiki templates.
  3. = in your code will confuse the wiki parser UNLESS you use {{|}}1= before it. Otherwise, the parser thinks everything before the fires = is the name of some wiki template parameter, and you'll see no code displayed at all. Meta:Help:Template for more on this.


Advertisement: