Difference between revisions of "Template:Malaysian election result/top/sandbox"
imported>Alexander Iskandar |
imported>WOSlinker (border/cellpadding/cellspacing not needed due to wikitable class) |
||
| (One intermediate revision by one other user not shown) | |||
| Line 1: | Line 1: | ||
| − | {| class="wikitable collapsible {{#switch:{{{collapsed|}}}|yes=collapsed|auto=autocollapse|no=|}} | + | {| class="wikitable collapsible {{#switch:{{{collapsed|}}}|yes=collapsed|auto=autocollapse|no=|}}" style="background:#f9f9f9; border:1px #aaa solid; border-collapse:collapse; width:{{#expr:573<!-- |
Adapt width of table according to columns displayed | Adapt width of table according to columns displayed | ||
| Line 13: | Line 13: | ||
Put the ‘navbar’ (V•T•E) in table title area | Put the ‘navbar’ (V•T•E) in table title area | ||
| − | -->{{#ifexist:Template:<noinclude>Malaysian election result/doc</noinclude><includeonly>{{#switch:{{{jurisdiction|{{{1}}}}}}| | + | -->{{#ifexist:Template:<noinclude>Malaysian election result/doc</noinclude><includeonly>{{#switch:{{{jurisdiction|{{{1}}}}}}|Malaysia=Malaysian general|Malaysian=Malaysian general|Johor=Johor state|Kedah=Kedah state|Kelantan=Kelantan state|Malacca=Malacca state|Negeri Sembilan=Negeri Sembilan state|Pahang=Pahang state|Penang=Penang state|Perak=Perak state|Perlis=Perlis state|Sabah=Sabah state|Sarawak=Sarawak state|Selangor=Selangor state|Terengganu=Terengganu state|MAS=Malaysian general|JOH=Johor state|KED=Kedah state|KEL=Kelantan state|MEL=Malacca state|NSE=Negeri Sembilan state|PAH=Pahang state|PEN=Penang state|PRK=Perak state|PER=Perlis state|SAB=Sabah state|SAR=Sarawak state|SEL=Selangor state|TER=Terengganu state|}} {{#ifeq:{{{by}}}|yes|by-|}}election, {{{election|{{{2}}}}}}/{{{constituency|{{{4|{{{3}}}}}}}}}{{#if:{{{ballot|}}}|, ballot {{{ballot}}}|}}</includeonly>|{{navbar|<noinclude>Malaysian election result/doc</noinclude><includeonly>{{#switch:{{{jurisdiction|{{{1}}}}}}|Malaysia=Malaysian general|Malaysian=Malaysian general|Johor=Johor state|Kedah=Kedah state|Kelantan=Kelantan state|Malacca=Malacca state|Negeri Sembilan=Negeri Sembilan state|Pahang=Pahang state|Penang=Penang state|Perak=Perak state|Perlis=Perlis state|Sabah=Sabah state|Sarawak=Sarawak state|Selangor=Selangor state|Terengganu=Terengganu state|MAS=Malaysian general|JOH=Johor state|KED=Kedah state|KEL=Kelantan state|MEL=Malacca state|NSE=Negeri Sembilan state|PAH=Pahang state|PEN=Penang state|PRK=Perak state|PER=Perlis state|SAB=Sabah state|SAR=Sarawak state|SEL=Selangor state|TER=Terengganu state|}} {{#ifeq:{{{by}}}|yes|by-|}}election, {{{election|{{{2}}}}}}/{{{constituency|{{{4|{{{3}}}}}}}}}{{#if:{{{ballot|}}}|, ballot {{{ballot}}}|}}</includeonly>|mini=1|style=float:left;}}}}<!-- |
| − | Table ‘Title’ (e.g. “Malaysian general election, 2013” or | + | Table ‘Title’ (e.g. “Malaysian general election, 2013” or “Balingian by-election, 2014”) |
| − | -->{{#ifeq:{{{by}}}|yes|{{#switch:{{{jurisdiction|{{{1}}}}}}| | + | -->{{#ifeq:{{{by}}}|yes|{{#switch:{{{jurisdiction|{{{1}}}}}}|Malaysia=Malaysian general|Malaysian=Malaysian general|Johor=Johor state|Kedah=Kedah state|Kelantan=Kelantan state|Malacca=Malacca state|Negeri Sembilan=Negeri Sembilan state|Pahang=Pahang state|Penang=Penang state|Perak=Perak state|Perlis=Perlis state|Sabah=Sabah state|Sarawak=Sarawak state|Selangor=Selangor state|Terengganu=Terengganu state|MAS=Malaysian general|JOH=Johor state|KED=Kedah state|KEL=Kelantan state|MEL=Malacca state|NSE=Negeri Sembilan state|PAH=Pahang state|PEN=Penang state|PRK=Perak state|PER=Perlis state|SAB=Sabah state|SAR=Sarawak state|SEL=Selangor state|TER=Terengganu state|}} by-election, {{#if:{{{by-link|}}}|[[{{{by-link}}}|{{{election|{{{2}}}}}}]]|{{{election|{{{2}}}}}}}}|[[{{#switch:{{{jurisdiction|{{{1}}}}}}|Malaysia=Malaysian general|Malaysian=Malaysian general|Johor=Johor state|Kedah=Kedah state|Kelantan=Kelantan state|Malacca=Malacca state|Negeri Sembilan=Negeri Sembilan state|Pahang=Pahang state|Penang=Penang state|Perak=Perak state|Perlis=Perlis state|Sabah=Sabah state|Sarawak=Sarawak state|Selangor=Selangor state|Terengganu=Terengganu state|MAS=Malaysian general|JOH=Johor state|KED=Kedah state|KEL=Kelantan state|MEL=Malacca state|NSE=Negeri Sembilan state|PAH=Pahang state|PEN=Penang state|PRK=Perak state|PER=Perlis state|SAB=Sabah state|SAR=Sarawak state|SEL=Selangor state|TER=Terengganu state|{{{jurisdiction|{{{1}}}}}}}} election{{#if:{{{election|}}}|, {{{election}}}|{{#if:{{{2|}}}|, {{{2}}}}}}}]]}}<!-- |
| − | Constituency name (e.g. [[ | + | Constituency name (e.g. [[Balingian (state constituency)|Balingian]]) — Suppress if template transcluded into that article |
-->{{#ifeq:{{PAGENAME}}|{{{constituency_link|{{{3}}}}}}||{{#if:{{{constituency_link|{{{3|}}}}}}|: {{nowrap|[[{{{constituency_link|{{{3}}}}}}{{#if:{{{constituency|{{{4|}}}}}}|{{!}}{{{constituency|{{{4}}}}}}}}]]}}}}}}<!-- | -->{{#ifeq:{{PAGENAME}}|{{{constituency_link|{{{3}}}}}}||{{#if:{{{constituency_link|{{{3|}}}}}}|: {{nowrap|[[{{{constituency_link|{{{3}}}}}}{{#if:{{{constituency|{{{4|}}}}}}|{{!}}{{{constituency|{{{4}}}}}}}}]]}}}}}}<!-- | ||
| Line 24: | Line 24: | ||
-->{{#if:{{{ballot|}}}|, ballot {{{ballot}}}}}<!-- | -->{{#if:{{{ballot|}}}|, ballot {{{ballot}}}}}<!-- | ||
| − | Special title line if "reason" for by-election specified (e.g. Resignation of [[ | + | Special title line if "reason" for by-election specified (e.g. Resignation of [[Abdul Taib Mahmud]]) |
-->{{#if:{{{reason|}}}|<br />{{{reason|}}}}}<!-- | -->{{#if:{{{reason|}}}|<br />{{{reason|}}}}}<!-- | ||
| Line 34: | Line 34: | ||
-->{{!}}<!-- | -->{{!}}<!-- | ||
-->''The <!-- | -->''The <!-- | ||
| − | -->{{#if:{{{by|}}}|by-|{{{election|{{{2}}}}}} {{#switch:{{{jurisdiction|{{{1}}}}}}|| | + | -->{{#if:{{{by|}}}|by-|{{{election|{{{2}}}}}} {{#switch:{{{jurisdiction|{{{1}}}}}}||Malaysia|Malaysian|Johor|Kedah|Kelantan|Malacca|Negeri Sembilan|Pahang|Penang|Perlis|Perak|Sabah|Sarawak|Selangor|Terengganu|MAS|JOH|KED|KEL|MEL|NSE|PAH|PEN|PER|PRK|SAB|SAR|SEL|TER|=}}}}<!-- |
-->election will be held on <!-- | -->election will be held on <!-- | ||
-->{{#time:F j|{{{on|}}}}}<!-- | -->{{#time:F j|{{{on|}}}}}<!-- | ||
| Line 69: | Line 69: | ||
AUTOMATIC CATEGORY PLACEMENT IF FOR A CONSTITUENCY | AUTOMATIC CATEGORY PLACEMENT IF FOR A CONSTITUENCY | ||
| − | -->{{#if:{{{ | + | -->{{#if:{{{constituency_link|{{{3|}}}}}}<!-- |
CATEGORY FOR BY-ELECTIONS | CATEGORY FOR BY-ELECTIONS | ||
| − | -->|{{#ifeq:{{{by}}}|yes|{{category handler|template=[[Category:{{#switch:{{{jurisdiction|{{{1}}}}}}| | + | -->|{{#ifeq:{{{by}}}|yes|{{category handler|template=[[Category:{{#switch:{{{jurisdiction|{{{1}}}}}}|Malaysia=Malaysian general|Malaysian=Malaysian general|Johor=Johor state|Kedah=Kedah state|Kelantan=Kelantan state|Malacca=Malacca state|Negeri Sembilan=Negeri Sembilan state|Pahang=Pahang state|Penang=Penang state|Perak=Perak state|Perlis=Perlis state|Sabah=Sabah state|Sarawak=Sarawak state|Selangor=Selangor state|Terengganu=Terengganu state|MAS=Malaysian general|JOH=Johor state|KED=Kedah state|KEL=Kelantan state|MEL=Malacca state|NSE=Negeri Sembilan state|PAH=Pahang state|PEN=Penang state|PRK=Perak state|PER=Perlis state|SAB=Sabah state|SAR=Sarawak state|SEL=Selangor state|TER=Terengganu state|}} by-election results by constituency]]|nocat={{{nocat|}}}}}<!-- |
YEAR CATEGORY FOR GENERAL ELECTIONS | YEAR CATEGORY FOR GENERAL ELECTIONS | ||
| − | -->|{{category handler|template=[[Category:{{#switch:{{{jurisdiction|{{{1}}}}}}| | + | -->|{{category handler|template=[[Category:{{#switch:{{{jurisdiction|{{{1}}}}}}|Malaysia=Malaysian general|Johor=Johor state|Kedah=Kedah state|Kelantan=Kelantan state|Malacca=Malacca state|Negeri Sembilan=Negeri Sembilan state|Pahang=Pahang state|Penang=Penang state|Perak=Perak state|Perlis=Perlis state|Sabah=Sabah state|Sarawak=Sarawak state|Selangor=Selangor state|Terengganu=Terengganu state|MAS=Malaysian general|JOH=Johor state|KED=Kedah state|KEL=Kelantan state|MEL=Malacca state|NSE=Negeri Sembilan state|PAH=Pahang state|PEN=Penang state|PRK=Perak state|PER=Perlis state|SAB=Sabah state|SAR=Sarawak state|SEL=Selangor state|TER=Terengganu state|}} election, {{{election|{{{2}}}}}} results by constituency]]|nocat={{{nocat|}}}}}}}<!-- |
COMPLETE LIST | COMPLETE LIST | ||
Latest revision as of 17:37, 7 June 2020
| [[{{{1}}} election]] | ||||||||
|---|---|---|---|---|---|---|---|---|
| Party | Candidate | Votes | % | ∆% | Expenditures | |||
| 50px | This is the template sandbox page for Template:Malaysian election result/top (diff). |
| Editors can experiment in this template's sandbox (edit | diff) and testcases (create) pages. Please add categories to the /doc subpage. Subpages of this template. |
| 50px | This is the template sandbox page for Template:Malaysian election result/top (diff). |
The template {{Malaysian election result}} is intended to create tables showing the election or by-election results in one constituency. It can be used on the pages of the constituencies, of the candidates, or on template pages that are transcluded onto both. It works in conjunction with five other templates: {{Malaysian election result/top}}, {{Malaysian election result/total}}, {{Malaysian election result/gain}}, {{Malaysian election result/hold}}, and {{Malaysian election result/source}}.
/top template
Begin each table with {{MASelec/top}}.
The first thing that needs to be specified is whether this is a general election, or state election.
Use the country name (for example Malaysia) or state name (for example Pahang). A table is given at the bottom of this page.
General format
- Basic form
Use {{MASelec/top|jurisdiction|election}}. The jurisdiction field should be the state name and the election field should be the year.
For example, {{MASelec/top|Kedah|2018}} gives:
| Party | Candidate | Votes | |
|---|---|---|---|
- With constituency name
Use {{MASelec/top|jurisdiction|election|constituency|constituency display}}. The constituency display field can be omitted when the constituency's article name does not contain disambiguation.
For example, {{MASelec/top|Malaysia|2018|Langkawi (federal constituency)|Langkawi}} gives:
| Party | Candidate | Votes | |
|---|---|---|---|
- With extra data columns
Extra columns can be added to provide additional dato. For example, {{MASelec/top|Malaysia|2018|Langkawi (federal constituency)|Langkawi|percent=yes|change=yes|expenditures=yes}} gives:
| Party | Candidate | Votes | % | ∆% | Expenditures | |
|---|---|---|---|---|---|---|
General parameters
- first unnamed parameter; or
jurisdiction= - This is the full title of the country name (for example
Malaysia) or state name (for examplePahang).
- second unnamed parameter or
election= - This is the four-digit year for a general election, or some other text (for example a full date) for a by-election.
- third unnamed parameter or
constituency= - This is the full title of a Wikipedia article about a constituency. For example:
Pekan (federal constituency)
- (optional) fourth unnamed parameter or
constituency_display= - This is the displayed text for the constituency name, if different from the above. For example:
Pekan
Optional parameters
- by=yes
- Use for by-elections. When using this, give the full date of the by-election rather than just the year.
- reason=
- Explain the reason for the by-election. For example,
reason=upon the resignation of Abdul Taib Mahmud. - percent=yes
- Use this parameter to add a column with the heading "%".
- change=yes
- Use this parameter to add a column with the heading "∆%".
- expenditures=yes
- Use this parameter to add a column with the heading "Expenditures".
- elected=yes
- Use for multi-member constituencies that elect multiple members off of one ballot to add a column with the heading "Elected".
- 1st=yes|percent=yes|final=yes|percent2=yes
- Use these parameters to create columns for multi-round elections.
- ballot=A or ballot=B or ballot=C
- Use one of these parameters for multi-member constituencies that run multiple ballots each with a different slate of candidates during each election. It will only change the links in the heading.
- collapsed=
- The table is by default collapsible. You can set the initial collapsedness as follows:
yes,auto, orno. These correspond to initial states of "collapsed", "autocollapse", or none, as documented at Help:Collapsing. For instance, if an article about a riding has a long list of election results from years past, you may want to have the first one display (for the most recent election) but keep the previous election years collapsed.
Main template
Use a copy of this template, {{Malaysian election result}}, for each row. The basic version of template is {{MASelec |jurisdiction |party |candidate |votes}}. The jurisdiction must be the country name or state name for state elections. The party name must match the format of party names in the "input text" column of the master list of parties. The candidate name can be wikilinked if the article exists. The full version of this template is {{MASelec |jurisdiction |party |candidate |votes |4th column |5th column |6th column}}. The last three fields are optional, and what should be put in them depends on what headers were used. For multi-member constituencies, use elected=yes to add a checkmark in the "Elected" column.
/total template
Use a copy of this template, {{MASelec/total}}, for each total row (for example, Total valid votes, Total rejected ballots, Unreturned ballots, Turnout, Registered electors, Majority). The full version of this template is {{MASelec/total |heading |votes column |4th column |5th column |6th column}}. The last three fields are optional.
See Malaysian election result/total documentation for instructions on how to find the data and complete the various total rows.
/gain and /hold templates
These templates can be used to identify gains and holds for the winning party, together with the swing calculated for the result compared to the previous election. The basic version of template is {{MASelec/gain |jurisdiction |gaining party |losing party |swing}} and {{MASelec/hold |jurisdiction |party |swing}}, with the jurisdiction and party input in the same way as in {{MASelec}}. The /gain template may additionally add the party that the seat was taken from in the third parameter.
Swing calculated using the formula ((∆%₁− ∆%₂) ÷ 2 ) (i.e. Change in winner's percentage compared to previous year minus change in second place percentage divided by two)
For example, {{MASelec/gain |Malaysia |PKR |BN |+10.30}} produces:
| PKR gain from BN | Swing | +10.30 | |||
/source and /note templates
These templates can be used to add a row to the bottom of the table. For example: {{MASelec/source|All data comes from Election Commission of Malaysia.}}. If the line of text contains an equals sign, as many government links do, name the field source=.
Links to multiple source can be added in an expandable “Source(s)}” section by assigning all the links to the parameter hide= (create separate lines by separating each source with <br />).
For example: {{MASelec/source|hide={{cite web |title=Source 1 |url=http://www.spr.gov.my/source1 |publisher=[[Election Commission of Malaysia]] |accessdate=14 August 2026}} in a table produces:
{{cite web |title=Source 2 |url=http://www.federalgazette.agc.gov.my/source2 |publisher= Attorney General's Chambers of Malaysia |accessdate=14 August 2026}} }}
| Party | Candidate | Votes | % | ∆% | ||
|---|---|---|---|---|---|---|
Source(s)
"Source 1". Election Commission of Malaysia. Retrieved 14 August 2026. "Source 2". Attorney General's Chambers of Malaysia. Retrieved 14 August 2026. | ||||||
end template
Finish election boxes with the {{end}} template.
Example
Here is an example using the federal constituency of Pandan in the 2018 federal election. The code:
{{MASelec/top|Malaysia|2018|Pandan (federal constituency)|Pandan|percent=yes|change=yes}}
{{MASelec||PH (2018)|[[Wan Azizah Wan Ismail]]|64,733|75.47|}}
{{MASelec||BN|Leong Kok Wee|12,190|14.21|}}
{{MASelec||PAS|Mohamed Sukri Omar|8,336|9.72|}}
{{MASelec||PRM|[[Lee Ying Ha]]|442|0.52|}}
{{MASelec||BEBAS|Mohd Khairul Azam Abdul Aziz|73|0.09|}}
{{MASelec/total|Total valid votes|85,774| 100.00}}
{{MASelec/total|Total rejected ballots|517|}}
{{MASelec/total|Unreturned ballots|223|}}
{{MASelec/total|Turnout|86,514|85.34}}
{{MASelec/total|Registered electors|101,379|}}
{{MASelec/total|Majority|52,543|61.26}}
{{MASelec/gain||PH (2018)|PKR|?}}
{{MASelec/source|hide={{cite web|url=http://www.federalgazette.agc.gov.my/outputp/pub_20180504_P.U.%20%28B%29%20239%20SELANGOR.pdf |title=His Majesty's Government Gazette - Notice of Contested Election, Parliament for the State of Selangor [P.U. (B) 239/2018]|date=3 May 2018|publisher=Attorney General's Chambers of Malaysia|accessdate=2018-08-01}}
{{cite web|url=http://www.federalgazette.agc.gov.my/outputp/pub_20180530_P.U.%20%28B%29%20313.pdf |title=Federal Government Gazette - Results of Contested Election and Statements of the Poll after the Official Addition of Votes, Parliamentary Constituencies for the State of Selangor [P.U. (B) 313/2018]|date=28 May 2018|publisher=Attorney General's Chambers of Malaysia|accessdate=2018-08-01}}}}
{{end}}
will produce:
| Party | Candidate | Votes | % | ∆% | ||
|---|---|---|---|---|---|---|
| PH | Wan Azizah Wan Ismail | 64,733 | 75.47 | |||
| BN | Leong Kok Wee | 12,190 | 14.21 | |||
| PAS | Mohamed Sukri Omar | 8,336 | 9.72 | |||
| PRM | Lee Ying Ha | 442 | 0.52 | |||
| Independent | Mohd Khairul Azam Abdul Aziz | 73 | 0.09 | |||
| Total valid votes | 85,774 | 100.00 | ||||
| Total rejected ballots | 517 | |||||
| Unreturned ballots | 223 | |||||
| Turnout | 86,514 | 85.34 | ||||
| Registered electors | 101,379 | |||||
| Majority | 52,543 | 61.26 | ||||
| PH gain from PKR | Swing | ? | ||||
Source(s) "His Majesty's Government Gazette - Notice of Contested Election, Parliament for the State of Selangor [P.U. (B) 239/2018]" (PDF). Attorney General's Chambers of Malaysia. 3 May 2018. Retrieved 2018-08-01. "Federal Government Gazette - Results of Contested Election and Statements of the Poll after the Official Addition of Votes, Parliamentary Constituencies for the State of Selangor [P.U. (B) 313/2018]" (PDF). Attorney General's Chambers of Malaysia. 28 May 2018. Retrieved 2018-08-01. | ||||||
TemplateData (main template)
This template produces one row in a table of Malaysian election results
| Parameter | Description | Type | Status | |
|---|---|---|---|---|
| Jurisdiction | 1 | Use three-letter codes. Malaysia=MAS, Johor=JOH, etc. For cities, use three-letter codes.
| Line | required |
| Party | 2 | Short-form name of the candidate's political party
| Line | required |
| Candidate | 3 | Name of the candidate. Can be wikilinked.
| Line | optional |
| Votes | 4 | Number of votes won by the candidate.
| Line | optional |
| 4th column | 5 | Adds text to the 4th column. Check the table's headings to see what information belongs in this column.
| Line | optional |
| 5th column | 6 | Adds text to the 5th column. Check the table's headings to see what information belongs in this column.
| Line | optional |
| 6th column | 7 | Adds text to the 6th column. Check the table's headings to see what information belongs in this column.
| Line | optional |
| Elected | elected | Used for ridings that elect multiple candidates on one ballot. Write 'yes' to add a checkmark in the last column.
| Line | optional |
See also
| The above documentation is transcluded from Template:Malaysian election result/doc. (edit | history) Editors can experiment in this template's sandbox (edit | diff) and testcases (create) pages. Subpages of this template. |
| [edit] |
|
|
References List |