Help:Templates

From Mud and Blood official Wiki
Jump to: navigation, search

Editor level required: Advanced

This is the page covering the basics from template use to template creation and how to work it all together.

Contents

Template Use

Why have Templates?

Templates allow an easy way to give information with pre-formatted text within. It is used to save space when creating pages, because certain templates can be over 100 lines long! They have a set of variables, or information that must be set to work. Lastly, templates can store information which gets updated on every page calling the template when the template is updated.

How to Use?

Each template comes with its own instructions on the page, but here are the basics:

  • To call a template, use {{Template Name . To close a template, use }}
  • To define a variable, use variable name = value
  • To separate variables, use pipes (|)

So, here is an example

{{Example| name  = Example| var1  = 100| image  = [[image:Image.png]]}}

Sometimes, for ease of reading, templates are aligned vertically, like this:

{{Example
| name  = Example
| var1  = 100
| image = [[image:Image.png]]
}}

Templates are specifically designed for certain pages, like some for help pages or others for Unit pages.

However, some are multi-use, namely the Generic Template.

Where to Place?

Usually, a template goes at the top of the page. Certain templates take priority over others, such as Template:Stub or Template:Real Life. Certain templates require the use of Template:Clear to re-start align all the text properly.

Template Creation

This is a skill that is very advanced!

To start off, create a page of the form Template:Template Name. This will ensure that the page can be called as a template.

Then you must add to it. If you plan to add instructions on how to use the template, use the tag to separarte the information you want from the instructions.

Then, you must actually make the template. We can start with some text. Imagine we made a template titled "Example1". We would need to make a page called: Template:Example1.

Within the page, we would insert the following syntax

<onlyinclude>Hello, world!</onlyinclude>

This means that whenever {{Example1}} is written, "Hello, world!" appears. Seems simple enough, right?

Now, try it with the welcome template, which is Template:Welcome. Writing {{Welcome}} gets the following message:

Welcome to the Mud and Blood official Wiki, Templates! This wiki is run by Urb and mostly created by the MnB community. As a reader, there are no real guidelines, you can just read the articles. However, as an editor, we have some rules to make sure the wiki looks neat and professional. If you need to learn how to edit, read the editing manual. If you are in need of stuff to edit, you can check the New Editor Guide or the Maintenance Portal. If you have any concerns, feel free to ask any officer, and if you have any questions feel free to contact any NCO or officer. A list of those users can be found at the staff page.

Here's a quick guide on how to edit the wiki:

<youtube v="5BK2yYWUVkE" />

Best of Wishes,

The Wiki Staff


See why a template may be useful?

Variables

In all honesty, templates with only one possible message are few and unnecessary. Usually, templates have variables. When adding a variable, you must use What you want it to appear like in the example. For example take a template, "Example2". We create the page like this:

<onlyinclude>The cost of this setup is {{{cost|18}}}} [[TP]].</onlyinclude>

To use the template, add {{Example2|cost = ???}} to the page. Define cost, and it will show up.

Personal tools