GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Main page
  • Contents
  • Current events
  • Random article
  • About Wikipedia
  • Contact us
  • Help
  • Learn to edit
  • Community portal
  • Recent changes
  • Upload file
  • Special pages
  • Search
  • Donate

This view

  • Original page
  • New address

GeezerVison is showing en.wikipedia.org — Help:Table/example row template - Wikipedia

< Help:Table
Documentationviewedithistorypurge

Note: For demonstration purposes only. For help with templates, see Help:Template. For help with tables, see Help:Table.

Why you might want to create a template like this:

Regardless of whether wikitext or HTML is used, rows within a table, and sometimes even within a collection of tables, may have much in common, e.g.:

  • the basic markup for a table row
  • code for color, alignment, and sorting mode
  • fixed texts such as units
  • special formats for sorting

In such a case, it can be useful to create a template that produces the syntax for a table row, with the data as parameters. This can have many advantages:

  • easily changing the order of columns, or removing a column
  • easily adding a new column if many elements of the new column are left blank (if the column is inserted and the existing fields are unnamed, use a named parameter for the new field to avoid adding blank parameter values to many template calls)
  • computing fields from other fields (e.g., population density from population and area)
  • duplicating content and providing span tags with display: none; for the purpose of having one format for sorting and another for display
  • easy specification of a format for a whole column, such as color and alignment

What this template does:

  1. Accepts two numeric parameters.
  2. Structures the output as a table row with three data cells.
    • First two cells hold the parameters in order.
    • Third cell holds the first divided by the second.
  3. Transcludes at the point of use.

Example

{| class="wikitable sortable"
|-
! a
! b
! a/b
{{help:table/example row template|  50|200}}
{{help:table/example row template|   8| 11}}
{{help:table/example row template|1000| 81}}
|}

gives:

a b a/b
502000.25
8110.72727272727273
10008112.345679012346
The above documentation is transcluded from Help:Table/example row template/doc. (edit | history)
Retrieved from "https://en.wikipedia.org/w/index.php?title=Help:Table/example_row_template&oldid=1202010017"
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.