User talk:Haemo/reply

Okay, a template is exactly like what a real template is; but in Wiki-terms. Let's say you were making signs for a garage sale, and you wanted them wanted to say "GARAGE SALE MY HOUSE, SATURDAY". If you have lots of signs to do, lettering them all by hand is tedious, and they might not look the same &mdash; you might make a mistake, or your letters might be different sizes. So, in the interests of time-saving, you take a piece of hard paper, cut out "GARAGE SALE MY HOUSE, SATURDAY" from it, then just spraypaint the paper onto each separate sign. They'll all look the same, and it will be much faster. Now, what if you also wanted to have a YARD sale? Well, you could make the GARAGE part of the template modular &mdash; so you could replace "GARAGE" with "YARD" if you wanted to. Likewise for "MY HOUSE" and "SATURDAY". Your template allows you to flexibly make a large number of signs quickly, with minimal effort.

Wikipedia templates are just like that, but in Wiki-markup. Templates are the Template: namespace, which is a special part of Wikipedia which act differently from all the rest. Specifically, everything is prefaced with the word "Template" &mdash; like Template:Cite. The code on a given template page is transcluded directly into the page when a template is used. "Transcluded" is a fancy word which basically means "included, but is not changed from page"; it's the opposite of substituted. This will make more sense with an example so let's look at this template: Template:Wrongtitle.

When we want to talk about the template (like above) we Wiki-link the name. When we want to use the template, we type the name in brackets like this:. Here's what that looks like:

The text you see is transcluded from the template. You can't change what it says by editing this page; you can only change it by editing the template page. However, if the template changes all instances of the template change across all pages. This is why many widely used templates are protected against vandalism; you can vandalize hundreds of pages with a single edit to a template &mdash; it's also hard to track down where the vandalism occured, since the pages do not appear to be edited. If you don't want your templates to update (for instance, with warnings) you can subsitute them like this:. Here's what that look like: (edit the page to look)

When you save the page, it converts that into the literal markup of the template. You might note that this template has a funny in it. That's because it take a variable which we have not supplyed. If you look at the documentation, you can see it need a variable "title". To tell a template what a variable should be, you declare it like this:. Here's what that looks like:

As you can see, this is like a "Mad Libs" or "fill in the blanks" game. Many templates are essentially shells into which you fill in the variables &mdash; like the citation templates or infoboxes for example. You just fill in the blanks with the information, and the template does the rest.

I hope this has been a useful introduction to templates. --Haemo (talk) 20:48, 13 June 2008 (UTC)