Jump to content

Help:Templates

From SeptemWiki
Revision as of 19:00, 19 March 2016 by Shawn (talk | contribs)

Templates are pages which can be included inside other pages by using the {{ }} syntax.

How the syntax works

At a basic level, if you put {{Namespace:Page}} into your page, then at that point, the contents of the page Namespace:Page will be included, regardless of the page.

For pages that are generally intended to be used as templates, if you put them in the Template: namespace, then you don't need to specify the namespace when using the curly braces, because that's what it assumes by default.

A template can be as simple as you like; if I create a page called Template:Jerkface and it just contains "Shawn Knight", then every place we put {{Jerkface}} in the wiki, "Shawn Knight" will appear. But then simply by editing Template:Jerkface to say "Alan Caum", every page which uses the template will show Alan's name instead.

Templates with Parameters

Sideling Hill Service Plaza

Actually there is no plaza named Template Demo, that would be a silly name; this is Sideling Hill Plaza.
Direction Eastbound and Westbound
County Fulton
State Kalmont


At a more advanced level, a template can have parameters, separated inside the curly braces by vertical bars. And generally a parameter has both a name and a value, connected by an equal sign.

Here's an example of an info box for a service plaza, using the PlazaBox template, with a number of parameters.

And the syntax which produces this can be written all in one line:

{{PlazaBox|county=Fulton|caption=Actually there is no plaza named Template Demo, that would be a silly name; this is Sideling Hill Plaza.|name=Sideling Hill|image=[[File:Sideling_Hill_Plaza.jpg|200px]]|direction=Eastbound and Westbound|state=Kalmont}}

Or broken down with each parameter on a line for readability:

{{PlazaBox
|county=Fulton
|caption=Actually there is no plaza named Template Demo, that would be a silly name; this is Sideling Hill Plaza.
|name=Template Demo
|image=[[File:Sideling_Hill_Plaza.jpg|200px]]
|direction=Eastbound and Westbound
|state=Kalmont}}

Notice that the names of the parameters do not appear in our syntax in the order they get used in the production of the template. Since they have names, we don't need to remember the correct order to put them in. We just have to know what the template allows us to use. Which is a matter of the template being well-documented.

Template Documentation

Here at SeptemWiki, we're trying to ensure that each template is well-documented. When you visit the template's page directly, like Template:PlazaBox, you should see some decent documentation on what the parameters are (if any) and how to put the template in your page.

Editing Templates

Not everyone with permission to edit an article has permission to edit templates, because you have the potential to break a lot of pages if you screw one up. If you need a template for something, either ask Shawn to do it or show him that you're really comfortable with the syntax.

All Template Pages