Template:Compact election box/sandbox
![]() | __EXPECTUNUSEDTEMPLATE__This is the template sandbox page for Template:Compact election box (diff). |
![]() | This template uses Lua: |
Purpose
A set of templates to produce a table displaying the results of first-past-the-post elections in a more compact format than offered by {{Election box}}.
Example
These templates produce results like this:
Election | Political result | Candidate | Party | Votes | % | ±% | ||
---|---|---|---|---|---|---|---|---|
1953 by-election death of Sir Bufton Tufton Electorate: 57,901 Turnout: 31,432 (66.2%) | Conservative gain from SNP Majority: 2,507 (12.5%) Swing: 17.1% from SNP to Con | Jimmy Smith | Conservative | 26,241 | 50.5 | N/A | ||
Dave Spart | Labour | 10,719 | 20.1 | N/A | ||||
1955 general election Electorate: 57,901 | Conservative hold | Jimmy Smith | Conservative | unopposed | ||||
1959 general election Electorate: 57,901 Turnout: 31,432 (66.2%) | Conservative hold Majority: 12,952 (19.5%) | Jimmy Smith | Conservative | 27,709 | 54.5 | N/A | ||
Dave Spart | Labour | 8,604 | 16.2 | N/A | ||||
Eric The Viking | Vikings for Borsetshire | 6,903 | 12.5 | N/A | ||||
1964 general election Electorate: 62,184 Turnout: 41,401 (69.8%) +3.6 | Labour gain from Conservative Majority: 2,011 (9.5%) | Dave Spart | Labour | 20,591 | 38.9 | +22.7 | ||
Jimmy Smith | Conservative | 18,709 | 33.4 | −22.1 | ||||
Col. Theo Smithers | Borsetshire Ratepayers | 1,903 | 6.7 | N/A | ||||
William Williamson | Liberal | 1,812 | 6.4 | N/A | ||||
Verte Profonde | Green | 1,561 | 6.0 | N/A | ||||
Egbert Monster | Monster Raving Loony | 912 | 3.1 | N/A | ||||
A. N. Ulsterman | UUP | 874 | 2.7 | N/A | ||||
A. Alba | SNP | 540 | 2.3 | N/A | ||||
1966 general election Electorate: 62,184 Turnout: 41,401 (69.8%) | Labour hold Majority: 2,011 (9.5%) +1.4 | Dave Spart | Labour | 20,591 | 39.9 | +1.1 | ||
Jimmy Smith | Conservative | 18,709 | 32.3 | −1.1 | ||||
Col. Theo Smithers | Borsetshire Ratepayers | 1,903 | 6.7 |
Usage
<syntaxhighlight lang="wikitext">
...
Election | Political result | Candidate | Party | Votes | % | ±% | ||
---|---|---|---|---|---|---|---|---|
' | win | ' | unopposed | |||||
' | win | ' | unopposed | |||||
' | win | ' | unopposed |
</syntaxhighlight>
Simple usage
Blank example with basic parameters <syntaxhighlight lang="wikitext">
<td style="background-color: parameter 1 should be a party name.">Election | Political result | Candidate | Party | Votes | % | ±% | ||
---|---|---|---|---|---|---|---|---|
' | win | ' | unopposed |
</syntaxhighlight>
Full usage
Blank example with all parameters <syntaxhighlight lang="wikitext">
<td style="background-color: parameter 1 should be a party name.">Election | Political result | Candidate | Party | Votes | % | ±% | ||
---|---|---|---|---|---|---|---|---|
' | ' | unopposed |
</syntaxhighlight>
Parameters
Header parameters
The parameters are used once
Parameter | Purpose | Example1 | Example2 |
---|---|---|---|
Required parameters | |||
election_title | title of election, may be wikilinked | [[Foobar South-Central by-election, 1953|1953 by-election]] | [[United Kingdom election, 1951|1951]] |
Optional parameters | |||
anchor, anchor2, anchor3 | a HTML anchor, to allow direct linking to the results for a particular election | anchor=GE2020result | anchor2=1917byelection |
election_ref | reference, usually to the source of the results | <ref>[http://www.foobar-politics-today.com Foobar South-Central by-election results], Politics Today</ref> | <ref name="somesource" /> |
election_note | very short note on the election. Probably best kept to a terse reason for a by-election | death of [[Sir Bufton Tufton]] | resignation of [[Jane Imefedup]] |
electorate | number of registered voters | 57,901 | |
turnout_votes | Number of ballots cast | 31,432 | |
turnout_percent | Turnout as a percentage of registered electors | 20.5 | 8.76 |
turnout_change | Change in turnout as a percentage of registered electors | +1.2 | −5.3 |
majority_votes | majority of the winning candidate in number of votes | 1,607 | |
majority_percent | Majority as a percentage of valid votes | +6.1 | −3.7 |
majority_change | Change in majority as a percentage of valid votes | +1.2 | −5.3 |
result | whether the seat changed party | hold, or gain (default=win) | |
loser_party | name of the party which lost, to be wikilinked | Social Democratic Party (UK) | Labour Party (UK) |
loser_party_unlinked | name of the party which lost, will not be wikilinked | Let's have a party all night Party | |
swing | swing in percentage | 4.3 | −6.8 |
swing_from | party which votes swung away from | Labour Party (UK) | |
swing_to | party which votes swung away from | Conservative Party (UK) |
Winner parameters
One set of these parameters for each candidate
Parameter | Purpose | Example |
---|---|---|
winner | Name of candidate (may be wikilinked) | [[Jimmy Abdul Rudigger Smith (junior)|Jimmy Smith]] |
winner_party | name of article on party | Conservative Party (UK) |
winner_party_unlinked | text of article on party | Borsetshire Free Lunch Party |
winner_votes | Number of votes received by the candidate | 26,241 |
winner_percent | Percentage of votes received by the candidate | 50.5 |
winner_change | Change in that party's percentage share of votes | −0.5 |
Candidate parameters
One set of these parameters for each candidate, starting candidate2. Maximum of 25.
Parameter | Purpose | Example |
---|---|---|
candidaten | Name of candidate (may be wikilinked) | [[Jimmy Abdul Rudigger Smith (junior)|Jimmy Smith]] |
candidaten_party | name of article on party | Conservative Party (UK) |
candidaten_party_unlinked | text of article on party | Borsetshire Free Lunch Party |
candidaten_votes | Number of votes received by the candidate | 26,241 |
candidaten_percent | Percentage of votes received by the candidate | 50.5 |
candidaten_change | Change in that party's percentage share of votes | +1.6 |
Anchors
By default, the template creates two anchors to the results of that election, using the following formats:
<election name as displayed> result
,<election name as displayed> result
, all converted to lowercase
So for example, on Bradford West (UK Parliament constituency), the table row for the 1970 general election has the automatically-generated anchors General election 1970 result
and general election 1970 result
. They can be can be linked to as Bradford West (UK Parliament constituency)#General election 1970 result and Bradford West (UK Parliament constituency)#general election 1970 result
Custom anchors
In addition to the auto-generated anchors, up to 3 custom anchors may be added using the parameters |anchor=
, |anchor2=
, and |anchor3=
.
For example, on Bradford Central (UK Parliament constituency), the entry for the 1886 by-election has the parameter |anchor=1886 unopposed
... which allows a link to Bradford Central (UK Parliament constituency)#1886 unopposed