Template:Election box US auto/doc

From blackwiki
Jump to navigation Jump to search

Usage

Basic

Example: {{election box US auto|California|2016|United States Representative District 7}}

United States House of Representatives elections, 2016[1]
Party Candidate Votes %
style="background-color: Template:Political party color; width: 5px;" | Democratic Ami Bera (Incumbent) 152,133 51.2%
style="background-color: Template:Republican Party (US)/meta/color; width: 2px;" | [[Republican Party (US)|Template:Republican Party (US)/meta/shortname]] Scott R. Jones 145,168 48.8%
Total votes 297,301 100.0%
style="background-color: Template:Political party color" | Democratic hold

Primary

You can also include primary information in the same box. Example: {{election box US auto|California|2016|State Assembly Member District 65|primary=yes}}


California State Assembly election, 2016[2][1]
Primary election
Party Candidate Votes %
style="background-color: Template:Political party color; width: 2px;" | Democratic Sharon Quirk-Silva 42,890 54.3%
style="background-color:
  1. REDIRECT Template:Republican Party (California)/meta/color


  • From a page move: This is a redirect from a page that has been moved (renamed). This page was kept as a redirect to avoid breaking links, both internal and external, that may have been made to the old page name.
; width: 2px;" |
[[California Republican Party|
  1. REDIRECT Template:Republican Party (California)/meta/shortname


  • From a page move: This is a redirect from a page that has been moved (renamed). This page was kept as a redirect to avoid breaking links, both internal and external, that may have been made to the old page name.
]]
Young Kim (Incumbent) 36,028 45.7%
Total votes 78,918 100.0%
General election
style="background-color: Template:Political party color; width: 5px;" | Democratic Sharon Quirk-Silva 79,654 53.2%
style="background-color:
  1. REDIRECT Template:Republican Party (California)/meta/color


  • From a page move: This is a redirect from a page that has been moved (renamed). This page was kept as a redirect to avoid breaking links, both internal and external, that may have been made to the old page name.
; width: 2px;" |
[[California Republican Party|
  1. REDIRECT Template:Republican Party (California)/meta/shortname


  • From a page move: This is a redirect from a page that has been moved (renamed). This page was kept as a redirect to avoid breaking links, both internal and external, that may have been made to the old page name.
]]
Young Kim (Incumbent) 69,941 46.8%
Total votes 149,595 100.0%
style="background-color: Template:Political party color" | Democratic gain from [[California Republican Party|
  1. REDIRECT Template:Republican Party (California)/meta/shortname


  • From a page move: This is a redirect from a page that has been moved (renamed). This page was kept as a redirect to avoid breaking links, both internal and external, that may have been made to the old page name.
]]

References

Autolinking

The template automatically tries to create links to candidates if they have pages. If the candidate's exact name has an article, then it will further check if it is a redirect, and follow it if so. Some candidates have redirects to the articles about their election, so we won't follow redirects to articles with the word "elections" in them. If no article exists (or it was a redirect to the election page), then no link is created unless |redlinks=1 was passed.

Sometimes you want to manually control the link target, like in cases where there's a disambiguation page. You can do so by passing a parameter in the format of |<name> link=target. For example, if the name in the dataset is Bernard "Bernie" Sanders, you would use |Bernard "Bernie" Sanders link=Bernie Sanders.


A {{election box}} template for US elections that automatically builds the table using tabular data from Commons.

Template parameters

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
State1

no description

Example
California
Stringrequired
Year2

Year the election took place. Can also be a comma separated list of years for multiple boxes

Example
2016
Numberrequired
Contest3

Name of the contest as specified in the tabular data

Example
United States Representative District 8
Stringrequired
Typetype

Type of election, can be "Primary"

Default
"General"
Stringoptional
Holdhold

"held" if the same party held the seat, or "flip" if Democrats/Republicans switched.

Example
held
Unknownoptional
Gain partygain

Name of party which gains the seat

Example
Democratic
Stringoptional
Loser partyloser

Name of party that lost the seat

Example
Democratic
Stringoptional
Primaryprimary

Whether to include primary information in the same template

Default
no
Example
yes
Stringoptional
no headingsno headings

Whether to disable automatic headings when multiple boxes are being generated (comma separated list of years)

Default
no
Example
yes
Stringoptional