Difference between revisions of "Template:Election box US auto/doc"
imported>Legoktm (document multi-mode) |
imported>Legoktm (→Multiple years: document parameter overrides for specific years) |
||
| Line 10: | Line 10: | ||
{{election box US auto|California|2016|State Assembly Member District 65|primary=yes}} | {{election box US auto|California|2016|State Assembly Member District 65|primary=yes}} | ||
===Multiple years=== | ===Multiple years=== | ||
| − | And you can have multiple boxes generated at the same time. Example: {{tlx|election box US auto|California|2012,2014,2016|United States Representative District 7}}. The automatic section headings can be disabled with <code>|no headings=yes</code>. | + | And you can have multiple boxes generated at the same time. Example: {{tlx|election box US auto|California|2012,2014,2016|United States Representative District 7}}. The automatic section headings can be disabled with <code>|no headings=yes</code>. To pass a parameter for a specific year, you can prefix it with the year it's for. So <code>|hold=held</code> for the 2012 box becomes <code>|2012 hold=held</code>. This will override any year-less parameters, which will apply to all years. |
{{election box US auto|California|2012,2014,2016|United States Representative District 7}} | {{election box US auto|California|2012,2014,2016|United States Representative District 7}} | ||
Revision as of 05:03, 13 November 2018
| File:Edit-copy green.svg | This is a documentation subpage for Template:Election box US auto. It contains usage information, categories and other content that is not part of the original template page. |
| 30px | This template uses Lua: |
Usage
Basic
Example: {{election box US auto|California|2016|United States Representative District 7}}
| 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}}
| 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:
|
[[California Republican Party|
|
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:
|
[[California Republican Party|
|
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|
| |||||
Multiple years
And you can have multiple boxes generated at the same time. Example: {{election box US auto|California|2012,2014,2016|United States Representative District 7}}. The automatic section headings can be disabled with |no headings=yes. To pass a parameter for a specific year, you can prefix it with the year it's for. So |hold=held for the 2012 box becomes |2012 hold=held. This will override any year-less parameters, which will apply to all years.
2012
| Party | Candidate | Votes | % | |||
|---|---|---|---|---|---|---|
| style="background-color: Template:Political party color; width: 5px;" | | Democratic | Ami Bera | 141,241 | 51.7% | ||
| style="background-color: Template:Republican Party (US)/meta/color; width: 2px;" | | [[Republican Party (US)|Template:Republican Party (US)/meta/shortname]] | Dan Lungren (Incumbent) | 132,050 | 48.3% | ||
| Total votes | 273,291 | 100.0% | ||||
| style="background-color: Template:Political party color" | | Democratic gain from [[Republican Party (US)|Template:Republican Party (US)/meta/shortname]] | |||||
2014
| Party | Candidate | Votes | % | |
|---|---|---|---|---|
| style="background-color: Template:Political party color; width: 5px;" | | Democratic | Ami Bera (Incumbent) | 92,521 | 50.4% |
| style="background-color: Template:Republican Party (US)/meta/color; width: 2px;" | | [[Republican Party (US)|Template:Republican Party (US)/meta/shortname]] | Doug Ose | 91,066 | 49.6% |
| Total votes | 183,587 | 100.0% | ||
| style="background-color: Template:Political party color" | | Democratic hold | |||
2016
| 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 | |||
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.
| Parameter | Description | Type | Status | |
|---|---|---|---|---|
| State | 1 | no description
| String | required |
| Year | 2 | Year the election took place. Can also be a comma separated list of years for multiple boxes
| Number | required |
| Contest | 3 | Name of the contest as specified in the tabular data
| String | required |
| Type | type | Type of election, can be "Primary"
| String | optional |
| Hold | hold | "held" if the same party held the seat, or "flip" if Democrats/Republicans switched.
| Unknown | optional |
| Gain party | gain | Name of party which gains the seat
| String | optional |
| Loser party | loser | Name of party that lost the seat
| String | optional |
| Primary | primary | Whether to include primary information in the same template
| String | optional |
| no headings | no headings | Whether to disable automatic headings when multiple boxes are being generated (comma separated list of years)
| String | optional |
- ↑ 1.0 1.1 1.2 https://elections.cdn.sos.ca.gov/sov/2016-general/sov/csv-candidates.xls
- ↑ https://elections.cdn.sos.ca.gov//sov/2016-primary/csv-voter-nominated-candidates.xls
- ↑ https://elections.cdn.sos.ca.gov/sov/2012-general/06-sov-summary.xls
- ↑ https://elections.cdn.sos.ca.gov/sov/2014-general/xls/06-summary.xls