Jump to content

Template:Election box US auto/doc

From Wikipedia, the free encyclopedia

Usage

[edit]

Basic

[edit]

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

United States House of Representatives elections, 2016[1]
Party Candidate Votes %
Democratic Ami Bera (Incumbent) 152,133 51.2%
Republican Scott Jones 145,168 48.8%
Total votes 297,301 100.0%
Democratic hold

Primary

[edit]

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 %
Democratic Sharon Quirk-Silva 42,890 54.3%
Republican Young Kim (Incumbent) 36,028 45.7%
Total votes 78,918 100.0%
General election
Democratic Sharon Quirk-Silva 79,654 53.2%
Republican Young Kim (Incumbent) 69,941 46.8%
Total votes 149,595 100.0%
Democratic gain from Republican

References

Autolinking

[edit]

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