Template:Range

From Wikipedia, the free encyclopedia
Jump to: navigation, search
Template documentation[view] [edit] [history] [purge]

This is the {{range}} meta-template.

It is used to show only parts of a list of items. This means that an article can call for instance a navbox with a year range as parameter, and only those items within the year range in the navbox will be visible. Thus keeping the navbox display small, but still you only need to manage one single navbox for the whole list.

Note that the "years" here can be any kind of number, so this template can be used for other ranges too. Even negative numbers and real numbers such as −2.85 work fine.

Usage[edit]

This template takes four parameters. The "item" is only shown if the "item year" is within the year range. Like this:

{{range|start_year|end_year|item_year|item}}

If "start year" is left empty them the item is shown. This is usually the case when a navbox that uses this template is viewed on its own template page. Then we want to see all items. Like this:

{{range|||item_year|item}}

Here is an example how this template can be used inside a navbox list:

{{range | {{{1|}}} | {{{2|}}} | 1969 | [[Apollo 11]]{{·}} 
}}{{range | {{{1|}}} | {{{2|}}} | 1969 | [[Apollo 12]]{{·}} 
}}{{range | {{{1|}}} | {{{2|}}} | 1971 | [[Apollo 14]]{{·}} 
}}

Note that there must be no newline between the end braces of one {{range}} and the begin of the next one. But there may be spaces.

For example: {{range|1991|2000|1992|XXX}}
Produces: XXX
While: {{range|1991|2000|1990|XXX}}
Produces:

Technical details[edit]

This template has built-in linewrap handling.

Under construction[edit]

This is still being tested. Do not use it yet!

The code now seems fully functional. What is lacking is the documentation of the "separator" feature and the convenience templates {{range·}}, {{range•}} and so on.

For usage examples see the {{range/testcases}} subpage.

--David Göthberg (talk) 11:25, 25 May 2008 (UTC)