SourceWatch:Templates

From SourceWatch
Jump to navigation Jump to search
SourceWatch utilizes a variety of templates to automate certain functions and displays. This help page is a guide for using them.

How to use templates: general

A template is called by using two curly brackets like this:
{{example template}}

Using variables

Templates generally utilize inputs in a call, either through variables named in the template or through variables that are simply set in a predefined order. Inputs for variables are separated by "pipes". (This: | is a pipe.) The guides below detail how the variables are set up for each of the templates used on SourceWatch.

If a template uses named variables, you must define the variables in the call, separated by pipes:
{{example template|Father=Joe|Mother=Mary|Great Aunt=Claire}}

If a template uses ordered variables, you simply enter the inputs in the correct order:
{{example template|Joe|Mary|Claire}}

In either case, you can put the template call all in one line (as above) or use multiple lines like this:

Templates using named variables Templates using ordered variables
{{example template
| Father=Joe
| Mother=Mary
| Great Aunt=Claire}}
{{example template
| Joe
| Mary
| Claire}}

<noinclude> and <includeonly>

Sometimes it is useful to include text or code in a template that applies only to pages the template is used on but is not applied to the template page itself. To do this, include a "<includeonly>" tag at the beginning of that content and a "</includeonly>" tag at the end. You would use this, for example, if you included a category tag in the template because you wanted every article with that template to show up in that category but you don't want the template page itself showing up in the category.

For example, Template:Stub uses this to put every page it is applied to (by adding "{{stub}}" to the page) in the Category:Stub while not putting the Template:Stub page in the category as well.

The inverse of that tag is the "<noinclude>" tag. This is used to put content on the template page that will not be fed into pages where the template is applied. To do this, include a "<noinclude>" tag at the beginning of that content and a "</noinclude>" tag at the end. You would use this, for example, if you wanted to include instructions or notes related to the template on the template's page without having those notes show up on the pages the template is applied to.

For example, Template:Main contains instructions on how to use it but uses the "<noinclude>" tag to keep those instructions from showing up on every page the template is used on.

Links to main articles

A convenient and eye-catching way to link to a larger SourceWatch article on a topic is to use the "Main article" template. You input this:

What you put in What you get

{{Main | Insert main article name here}}

Main article: Insert main article name here

Here's a real example:

Main article: Ethics in Congress

Link to the template: Template:Main article


Types of templates used on SourceWatch

Articles and resources

External links