Help:Template

From Homestar Runner Wiki

Revision as of 22:17, 23 October 2006 by Qermaq (Talk | contribs)
Jump to: navigation, search


Wiki users can create and use templates. A template is a means of creating a section of a page, or even a whole page, by using a short name plus any number of "inputs", which will be used in place of numbers in the text actually displayed. Here's the basics on how to create and use templates.

Contents

Creating a template

HRWiki:Template messages is a list of existing templates. Please check there to be sure your idea for a template has not been done yet.

Usage

First, consider what the template would be used for. What would its purpose be? Some common uses are:

Syntax

Make sure you know the MediaWiki syntax for a template:

  • For an input, type {{{1}}} for the first input, {{{2}}} for the second, and so on.
    • In a more complicated template, where one might not easily remember the order of which input is which, this can be substituted with {{{value}}} or another more meaningful name, like {{{name}}} or {{{old page}}}.
  • For current page information, type {{NAMESPACE}} for the page’s namespace, and {{PAGENAME}} for the page’s name.
    • These will be inserted and changed as the location of the template changes.

Including text in a template

To include text in the template that you don't want to show up in pages that use it, such as:

  • Instructions on how to use the template
  • A category to organize the template

Place the text in a set of <noinclude> tags at the bottom of the template page.

Using a template

Make sure you know how to use the template once it’s been created:

  • If the template is in a Template: namespace, simply type {{its name}} to use it.
  • If the template is in any other namespace, simply type {{Namespace:its name}} to use it.
  • For an input {{{1}}}, type {{its name|input 1|input 2|etc...}}.
  • For an input {{{value}}}, type {{its name|value = input 1}}.

Substituting text for template

For some templates, it is a better idea to take load off the server and use subst: before the template name. This substitutes the dynamic code on the page with static text. For example, just typing {{tick}} will result in {{tick}} being added to the code, while typing {{subst:tick}} will result in, say, [[Image:wiki tick.GIF]] (or whatever the template's results are) being added to the code. Both will appear the same to the reader, but the latter one does not call up the template every time.

Example

Here is a simple example, creating a signature for any user typing {{Sig|User}}:

If the template contains the code:
[[User:{{{1}}}|{{{1}}}]] ([[User talk:{{{1}}}|talk]] · [[Special:Contributions/{{{1}}}|edits]])
Typing {{Sig|user}} inserts this code:
[[User:User|User]] ([[User talk:User|talk]] · [[Special:Contributions/User|edits]])
Which shows on the page as:
User (talk · edits)
Personal tools