Template:United States presidential election results table row/sandbox
This is the template sandbox page for Template:United States presidential election results table row (diff). See also the companion subpage for test cases. |
This template is used on approximately 3,400 pages and changes may be widely noticed. Test changes in the template's /sandbox or /testcases subpages, or in your own user subpage. Consider discussing changes on the talk page before implementing them. |
Usage
[edit]This is used to form the rows of United States Presidential election tables, alongside {{PresHead}} and {{PresFoot}} for that purpose, like so:
{{PresHead|PresHead parameters...}}
{{PresRow|PresRow parameters...}}
{{PresRow|PresRow parameters...}}
.
.
.
{{PresRow|PresRow parameters...}}
{{PresFoot|PresFoot parameters...}}
It (PresRow) automatically calculates the percentages won from each party based on the data entered, and automatically bolds the party winner. It may also be placed at the bottom of the table in place of PresFoot, which is identical to this template (and indeed a transclusion of it) with the ending cap of a WikiTable attached to it:
.
.
.
{{PresRow|PresRow parameters...}}
|}
This is suboptimal, however, and one is better off using PresFoot. The testcase page for all three templates is that of this one, and can be found here.
None of the parameters are named, and must be entered in order as follows:
{{PresRow| Year of election (by default 2020)| Party winner | Vote towards Republican/Whig candidate | Vote towards Democratic candidate | Vote towards third-party candidates | State}}
Important information on whitespace:
The party winner field should note the party exactly as its name is written in the "Template:Party shading/" subpage, without any whitespace between it and the pipe. For example, a GOP win should be written exactly, without quotes, as "|Republican" and a Democratic one "|Democratic" (NOTE the "-ic" at the end). In addition, please do not put any whitespace after the vote values, though this is for aesthetic reasons rather than coding. Whitespace shouldn't matter anywhere else.
Aliases:
Substitution:
PresHead and PresFoot should NOT be substituted. The code works just the same if they are, but it is not best practice to substitute them. PresHead should not be substituted because it doesn't speed up the performance of the page appreciably and leaves it unable to automatically conform to any changes to the template (however low a chance they may have of happening). PresFoot should not be substituted because it won't necessarily be the earliest Presidential election available (earlier data may yet be found, for example), and it leaves a "cap" to the wikitable that proves a slight inconvenience to remove.
PresRow (this particular template) may be substituted at the discretion of the editor to help avoid the transclusor (i.e., the page on which the template is transcluded) reaching the template limits. Either {{subst:}}
or {{safesubst:}}
work.