Format Rules/Templates: Difference between revisions

From All The Fallen Stories
Jump to navigation Jump to search
Elerneron (talk | contribs)
No edit summary
Elerneron (talk | contribs)
m Protected "Format Rules/Templates" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite))
 
(2 intermediate revisions by the same user not shown)
Line 10: Line 10:
Let's make a basic status bar for a Game-type story as an example.  In this example I will also be using some table markup and XHTML attributes, but that is not necessary for a template.  They follow the same rules as a normal page.
Let's make a basic status bar for a Game-type story as an example.  In this example I will also be using some table markup and XHTML attributes, but that is not necessary for a template.  They follow the same rules as a normal page.


{{Template:Status Sample}}
{{Sample Template}}


Now, you may have noticed that the parameters are all empty.  Well this will not do.  Lets fill them.  You fill a parameter by adding a vertical bar and the ParameterName=Value.  Do this for each parameter thus: <code><nowiki>{{Template:Status Sample|Health=100|MP=50|Level=1|Equipment=Wooden Sword, Peasant Clothes}}</nowiki></code>.  Notice that it is a bit cumbersome and difficult to read; and that's with just four parameters.  Well, you can break it up into multiple lines, thus:
Now, you may have noticed that the parameters are all empty.  Well this will not do.  Lets fill them.  You fill a parameter by adding a vertical bar and the ParameterName=Value.  Do this for each parameter thus: <code><nowiki>{{Sample Template|Health=100|MP=50|Level=1|Equipment=Wooden Sword, Peasant Clothes}}</nowiki></code>.  Notice that it is a bit cumbersome and difficult to read; and that's with just four parameters.  Well, you can break it up into multiple lines, thus:


<pre>{{Template:Status Sample
<pre>{{Sample Template
|Health=100
|Health=100
|MP=50
|MP=50
Line 23: Line 23:
Isn't that easier to read?  Now lets see what it looks like:
Isn't that easier to read?  Now lets see what it looks like:


{{Template:Status Sample
{{Sample Template
|Health=100
|Health=100
|MP=50
|MP=50

Latest revision as of 00:54, 6 September 2020

Using templates can make things a whole lot easier if you have a lot of repetition in your story. Basically, a template is a page that can be inserted into any other page. This is especially handy for Game-type stories.


To make a template, all one has to do is name the template, and surround it with double curly braces {{Template:My Template}}. Then, you click on the red link that it generates, and make your template page the way that you make a normal page. Templates should always be added to the story category as well as the template category, and categories should be surrounded by the <noinclude> tag so that the template doesn't pass on it's categories to the pages that it is placed on:

<noinclude>[[Category:My Story]] [[Category:Template]]</noinclude>

.

So that is handy in and of itself, but what really makes Templates truly useful is that they can accept Parameters. You can think of Parameters as bits of information that might change from one use of a template to the next. You can define a Parameter by placing the parameter name in triple curly braces where you want the information to show up on your Template page: {{{My Parameter}}}.


Let's make a basic status bar for a Game-type story as an example. In this example I will also be using some table markup and XHTML attributes, but that is not necessary for a template. They follow the same rules as a normal page.

Status Equipment:
Health {{{Health}}} {{{Equipment}}}
MP {{{MP}}}
Level {{{Level}}}


Now, you may have noticed that the parameters are all empty. Well this will not do. Lets fill them. You fill a parameter by adding a vertical bar and the ParameterName=Value. Do this for each parameter thus: {{Sample Template|Health=100|MP=50|Level=1|Equipment=Wooden Sword, Peasant Clothes}}. Notice that it is a bit cumbersome and difficult to read; and that's with just four parameters. Well, you can break it up into multiple lines, thus:

{{Sample Template
|Health=100
|MP=50
|Level=1
|Equipment=Wooden Sword, Peasant Clothes
}}

Isn't that easier to read? Now lets see what it looks like:

Status Equipment:
Health 100 Wooden Sword, Peasant Clothes
MP 50
Level 1


If you want to get into Templates more in depth, you can read more at https://meta.wikimedia.org/wiki/Help:Template.