Help:Creating templates
From WhatRumors: The Celebrity Gossip Wiki
|
A template is a piece of text (including tables, pictures, and code) that can be included into other pages. This allows that text to be edited in one place and then updated on many pages at once.
A template is any page in the template namespace, which means any page beginning with "Template:", such as Template:Templatename.
For basic information on how templates work, see Help:Templates.
How do I create a template?
Create a page in the Template namespace, by creating it with the title "Template:Your_template_name". The template name can include spaces and symbols, but you will want the name to be easy to remember and easy to type, so the shorter and simpler the better.
How do I use parameters in a template?
Templates allow you to pass parameters that can be used to affect the content or design of the template.
For example:
{{box|text}}
...might produce a box containing text.
Alternatively:
{{box|bgcolor=yellow|textcolor=blue|caption=A yellow house}}
...might produce a box with a yellow background and blue text, with a caption describing it as such.
How do I use parser functions in a template?
Parser functions allow you to use a little bit of programming logic in your templates, including "if" statements and basic calculations. For instance, you can hide table rows which contain empty parameters by using:
{{#if: {{{input|}}} | {{!}}-
{{!}} {{{input}}} }}
Produces the following code only if input is defined.
|- | input
{{!}} is used in the above parser function instead of | as the extension uses | to separate parameters. {{!}} is a template at Template:! which transcludes | into the code after the parser function has been validated.