@DeletedUser41170185 (talk | contribs) mNo edit summary |
@DeletedUser41170185 (talk | contribs) mNo edit summary |
||
Line 80: | Line 80: | ||
:tag('tr') |
:tag('tr') |
||
:tag('th') |
:tag('th') |
||
− | :css('width', '50%') |
||
:css('text-align', 'center') |
:css('text-align', 'center') |
||
:wikitext(args['trait' .. i] .. ':') |
:wikitext(args['trait' .. i] .. ':') |
||
:done() |
:done() |
||
:tag('td') |
:tag('td') |
||
− | :css('width', '50%') |
||
:wikitext(args['value' .. i]) |
:wikitext(args['value' .. i]) |
||
:done() |
:done() |
Revision as of 18:26, 15 April 2018
▶️
Planeshift.
The documentation for this module can be found at Template:Infobox.
You may be forwarded to another wiki language, in case a translation is not available.
Dependencies
local p = {}
local color = require('Module:Color')._main
local get_args = require('Module:Arguments').main
local defaults = {
['title-textcolor'] = 'white',
['title-bgcolor'] = color({'wiki1'}),
['heading-textcolor'] = 'black',
['heading-bgcolor'] = '#EADCDA',
['image-size'] = '256px',
}
function p.main()
local args = get_args()
return p._main(args)
end
function p._main(args)
-- Add the default values to the arguments.
setmetatable(args, { __index = defaults })
local infobox = mw.html.create('table')
:addClass('infobox')
:newline()
-- Add the infobox title.
:tag('tr')
:tag('th')
:attr('colspan', 2)
:css('background-color', args['title-bgcolor'])
:css('text-align', 'center')
:css('color', args['title-textcolor'])
:css('font-weight', 'bold')
:wikitext(args['title'])
:done()
:done()
:newline()
if args['image'] then
infobox
:tag('tr')
:tag('td')
:attr('colspan', 2)
:wikitext(string.format('[[File:%s|%s]]', args['image'], args['image-size']))
:done()
:done()
:newline()
end
local i = 1
while args['trait' .. i] do
-- Insert headings if necessary.
if args['heading' .. i] then
infobox
:tag('tr')
:tag('td')
:attr('colspan', 2)
:css('background-color', args['heading-bgcolor'])
:css('text-align', 'center')
:css('color', args['heading-textcolor'])
:css('font-weight', 'bold')
:wikitext(args['heading' .. i])
:done()
:done()
:newline()
end
if args["trait" .. i] == 'fullwidth' and args['value' .. i] then
infobox
:tag('tr')
:tag('td')
:attr('colspan', 2)
:cssText(args['stylevalue' .. i] or 'text-align: center;')
:wikitext(args['value' .. i])
:done()
:done()
:newline()
elseif args['value' .. i] then
infobox
:tag('tr')
:tag('th')
:css('text-align', 'center')
:wikitext(args['trait' .. i] .. ':')
:done()
:tag('td')
:wikitext(args['value' .. i])
:done()
:done()
:newline()
end
i = i + 1
end
return infobox
end
return p