Module:Wikitable
This module is rated as ready for general use. It has reached a mature form and is thought to be bug-free and ready for use wherever appropriate. It is ready to mention on help pages and other Wikipedia resources as an option for new users to learn. To reduce server load and bad output, it should be improved by sandbox testing rather than repeated trial-and-error editing. |
Usage
editThis module is designed to make passing tables to templates less of a hassle.
Often time, adding wikitable markup to a template or other parser tag generates gibberish when one fails to escape every |
and =
. Moreover, escaping pipe characters with {{!}}
everywhere can make for some rather ugly-looking markup.
With this module, most wikitables can be embedded into templates without escaping any pipe characters. Also, =
for <table>
element attributes do not need to be escaped, however, for individual rows and cells, such is still necessary. Finally, there must be at least one pipe character before the first header cell (only an issue if |-
is omitted before the first row)
original (copied from: 2016_Summer_Olympics):
code: {| class="wikitable" width="auto" style="text-align: center"
|-
! colspan="6" |2016 Summer Olympics bidding results<ref>{{cite web|url=http://www.gamesbids.com/eng/past.html |title=Past Bid Results |publisher=GamesBids.com |accessdate=31 October 2015 |archiveurl=https://www.webcitation.org/5xFvf0ufx?url=http://www.gamesbids.com/eng/past.html |archivedate=17 March 2011 |df=dmy }}</ref>
[[Image:Bids for the 2016 Summer Olympics.svg|center|500px]]
|- style="background:#efefef;"
! '''City'''
! '''NOC'''
| style="background: silver" |'''Round 1'''
| style="background: silver" |'''Round 2'''
| style="background: silver" |'''Round 3'''
|-
| style="text-align:left;" |''' [[Rio de Janeiro bid for the 2016 Summer Olympics|Rio de Janeiro]]'''
| style="text-align:left;" |''' {{BRA}}'''
| style="text-align:center;" | 26
| style="text-align:center;" |'''46'''
| style="text-align:center;" |'''66'''
|-
| style="text-align:left;" | [[Madrid bid for the 2016 Summer Olympics|Madrid]]
| style="text-align:left;" | {{ESP}}
| style="text-align:center;" |'''28'''
| style="text-align:center;" |29
| style="text-align:center;" |32
|-
| style="text-align:left;" |[[Tokyo bid for the 2016 Summer Olympics|Tokyo]]
| style="text-align:left;" | {{JPN}}
| style="text-align:center;" |22
| style="text-align:center;" |20
| style="text-align:center;" |—
|-
| style="text-align:left;" | [[Chicago bid for the 2016 Summer Olympics|Chicago]]
| style="text-align:left;" | {{USA}}
| style="text-align:center;" |18
| style="text-align:center;" |—
| style="text-align:center;" |—
|}
|
module:
code (with changes highlighted):[[:Module talk:Wikitable/example]] |
- ↑ "Past Bid Results". GamesBids.com. Archived from the original on 17 March 2011. Retrieved 31 October 2015.
local p = {};
local getArgs = require('Module:Arguments').getArgs
local buffer = require("Module:Buffer")('{|')
function p.main(frame)
local args = getArgs(frame, {removeBlanks=false, trim=false} )
for k, v in pairs(args) do
if type(k) ~= 'number' then buffer:_(string.format(string.match(v, '^["\']') and ' %s=%s' or ' %s="%s"', k, v)) end
end
buffer:_'\n'
for _, v in ipairs(args) do
if not string.match(v, '^!') then buffer:_'|' end
buffer:_(v)
end
return table.concat(buffer:_'\n|}')
end
return p;