Help:Templates

From Mario Fan Games Galaxy Wiki
Jump to: navigation, search
Wiki Basics
Wiki Editing
Wiki Formatting
Wiki Experience

Templates are special pages existing within the "Template" namespace. These pages are designed explicitly for other pages to call them (or rather, "include"), meaning you can use one page as content in many pages.

For instance, this page calls Template:Help, which may be edited to change the displayed help contents on all of the help pages that include it at once.

Templates are particularly useful for quickly embedding otherwise complex table code, while needing to give only the most vital information (see Template:MFGGer.)

Contents

Inclusion

Basic templates

Templates are included in a page with their name (WITHOUT THE "TEMPLATE:" PART) between point-curled brackets, as in {{-name-}}:

{{Help}}

This calls Template:Help. Except for the first letter ("H" in this case), all template names are case-sensitive. (e.g. {{Help}} and {{help}} are the same - but {{hElP}} is not)

Parameters

The true power of templates is that they may be passed parameters when included, which they will utilize in some manner depending on the template itself. For instance, calling the (fictional) "Template:Car-salesman" with relevant information may look something like:

{{car-salesman
|name=Fred
|age=46
|car-count=Lots
}}

Each | followed by a label is a parameter name. The text after the = indicates the value. Line breaks between each parameter are entirely optional and serve mainly to make larger templates more legible when called.

Depending on the template, the parameters may not be given explicit labels, and can be given without names as long as they are in the right order:

{{car-salesman|Fred|46|Lots}}

Will work the same, assuming that |name, |age, and |car-count are always the 1st, 2nd, and 3rd parameters, respectively.

Do not mix names and no-names in the same template include; the server will have trouble figuring out which is which, and so will any human editors.


Creation

Template creation is a difficult and potentially dangerous undertaking and can cause gigantic problems across the Wiki if done improperly. First off, the following points:

  • <noinclude> and </noinclude> will prevent the content between them from showing when the page is included. This is useful for adding documentation on the form and use of the template, and for categorizing the template without categorizing pages that include it.
  • <includeonly> and </includeonly> cause the content between them to only display and parse once included. This is primarily used for categorizing including pages without categorizing the template.

Using parameters

Recall that when calling a template, you may pass it a parameter:

{{Template
 |param = anything
 }}

In the template page, this parameter is called by its name in triple brackets.

<tr>
  <td>{{{param}}}</td>
</tr>

However, doing this will cause the text {{{param}}} to display if such a parameter was not given. To rectify this, place a | after its name, and after the | place alternate text to display when no value is given:

<tr>
  <td>{{{param|N/A}}}</td>
</tr>

Here, if |param was passed, its value will display. If no |param was given, "N/A" will display.


You can also use other parameters as the alternate text, which lets you create many aliases for the same value:

<tr>
  <th>Date of birth</th>
  <td>{{{birthday|{{{dob|}}}}}}</td>
</tr>

In this case, passing either {{{birthday}}} or {{{dob}}} will have the same effect.

This can get confusing; try not to add many aliases for one parameter.

Unnamed parameters

If you were, for some reason, to call a template and pass parameters without any names:

{{template|Bob|24|Golf}}

Then you would have to call them by number in your template:

 <table>
  <tr>
    <th colspan='2'>{{{1|NO NAME}}}</th>
  </tr>
  <tr>
    <th>Age</th>
    <td>{{{2|Not given}}}</td>
  </tr>
  <tr>
    <th>Hobbies</th>
    <td>{{{3|N/A}}}</td>
  </tr>
</table>

It is generally a good idea to use numbered parameters for templates that only require one or two, so that calling them is faster. For templates with many fields, especially if some of them are optional, it is better to ask for named parameters.

Types

There are several types of template as you could probably guess. MFGG currently has groups for

Some special ones have been covered in the rest of this guide.

Personal tools