Jump to content

Help:Templates: Difference between revisions

From SeptemWiki
Created page with "'''Templates''' are pages which can be included inside other pages by using the <code><nowiki>{{ }}</nowiki></code> syntax. == How the syntax works == At a basic level, if y..."
 
Line 11: Line 11:
== Templates with Parameters ==
== Templates with Parameters ==


At a more advanced level, a template can have parameters, separated inside the curly braces by vertical bars.  And generally a parameter has a name and a value.
{{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}}
 
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 <code>PlazaBox</code> template, with a number of parameters.
Here's an example of an info box for a service plaza, using the <code>PlazaBox</code> template, with a number of parameters.


{{PlazaBox|name=Sideling Hill Plaza|image=[[File:Sideling_Hill_Plaza.jpg|200px]]|caption=The plaza entrance|direction=Eastbound and Westbound|county=Fulton|state=Kalmont}}
And the syntax which produces this can be written all in one line:
 
<nowiki>{{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}}</nowiki>
 
Or broken down with each parameter on a line for readability:
 
<nowiki>{{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}}</nowiki>
 
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.


{{Clear}}


== Editing Templates ==
== Editing Templates ==

Revision as of 18:56, 19 March 2016

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.

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