@DeletedUser41170185 (talk | contribs) mNo edit summary |
@DeletedUser41170185 (talk | contribs) (Empty parameters are true instead of false in lua O.o) |
||
Line 30: | Line 30: | ||
infobox = infobox .. '| colspan="2" style="' .. style .. '" | ' .. args["value" .. n] .. '\n|-\n' |
infobox = infobox .. '| colspan="2" style="' .. style .. '" | ' .. args["value" .. n] .. '\n|-\n' |
||
else |
else |
||
− | if args["value" .. n] then |
+ | if args["value" .. n] ~= '' or nil then |
infobox = infobox .. '!' .. args['trait' .. n] .. ':\n| ' .. args["value" .. n] .. '\n|-\n' |
infobox = infobox .. '!' .. args['trait' .. n] .. ':\n| ' .. args["value" .. n] .. '\n|-\n' |
||
end |
end |
Revision as of 19:35, 3 December 2017
▶️
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 = {}
function p.main( frame )
local args = frame:getParent().args
return p._main( args )
end
function p._main( args )
local color = require('Module:Color').main
local title_textcolor = args["title-textcolor"] or 'white'
local title_background = args["title-bgcolor"] or color( 'wiki1' )
local heading_textcolor = args["heading-textcolor"] or 'black'
local heading_background = args["heading-bgcolor"] or '#EADCDA'
local infobox = '{| class="infobox"\n| colspan="2" style="text-align:center; color:' .. title_textcolor .. '; background-color:' .. title_background .. ';" | <span style="font-weight:bold;">' .. args["title"] .. '</span>\n|-\n| colspan="2" style="text-align:center;"|\n|-\n'
if args["image"] ~= '' or nil then
local image_size = args["image-size"] or '256px'
infobox = infobox .. '| colspan="2" | [[File:' .. args["image"] .. '|center|' .. image_size .. ']]\n|-\n'
end
local n = 1
while args["trait" .. n] do
if args["heading" .. n] then
infobox = infobox .. '| colspan="2" style="text-align:center; color:' .. heading_textcolor .. '; background-color:' .. heading_background .. '" | <span style="font-weight:bold;">' .. args["heading" .. n] .. '</span>\n|-\n'
end
if args["trait" .. n] == 'fullwidth' then
local style = args["stylevalue" .. n] or 'text-align:center;'
infobox = infobox .. '| colspan="2" style="' .. style .. '" | ' .. args["value" .. n] .. '\n|-\n'
else
if args["value" .. n] ~= '' or nil then
infobox = infobox .. '!' .. args['trait' .. n] .. ':\n| ' .. args["value" .. n] .. '\n|-\n'
end
end
n = n + 1
end
return infobox
end
return p