模組:Infobox
外觀
可在模組:Infobox/doc建立此模組的說明文件
local p = {}
function p.main(frame)
local args = frame:getParent().args
local root = mw.html.create("table")
:addClass("infobox")
:css("float", "right")
:css("clear", "right")
:css("margin", "0 0 1em 1em")
:css("width", "300px")
:css("border", "1px solid #a2a9b1")
:css("border-collapse", "collapse")
:css("background", "#f8f9fa")
:css("font-size", "90%")
local title = args.title or args.name or ""
if title ~= "" then
root
:tag("tr")
:tag("th")
:attr("colspan", "2")
:css("text-align", "center")
:css("font-size", "125%")
:css("font-weight", "bold")
:css("padding", "0.4em")
:css("background", "#eaecf0")
:wikitext(title)
:done()
:done()
end
local image = args.image or ""
if image ~= "" then
local row = root:tag("tr")
local cell = row
:tag("td")
:attr("colspan", "2")
:css("text-align", "center")
:css("padding", "0.5em")
cell:wikitext(image)
local caption = args.caption or ""
if caption ~= "" then
cell
:tag("div")
:css("font-size", "90%")
:css("margin-top", "0.3em")
:wikitext(caption)
:done()
end
cell:done()
row:done()
end
local i = 1
while true do
local label = args["label" .. i]
local value = args["data" .. i]
if not label and not value then
break
end
if value and value ~= "" then
local row = root:tag("tr")
if label and label ~= "" then
row
:tag("th")
:css("text-align", "left")
:css("vertical-align", "top")
:css("padding", "0.3em 0.5em")
:wikitext(label)
:done()
end
row
:tag("td")
:css("vertical-align", "top")
:css("padding", "0.3em 0.5em")
:wikitext(value)
:done()
row:done()
end
i = i + 1
end
return tostring(root)
end
return p