local p = {}
function p.main(frame)
local args = frame:getParent().args
-- 获取参数值,设置默认值
local bgcolor = args.bgcolor or '#00ffff'
local fontcolor = args.fontcolor or '#000000'
local class = args.class or '<span class="error">用户未填入分类</span>'
-- 构建样式
local style = string.format('background:%s; color:%s; font-size:85%%; padding:2px; border:2px; border-style:solid; border-radius:10px;width:225px;', bgcolor, fontcolor)
-- 开始构建输出
local output = {}
table.insert(output, string.format([=[
{| align=center width=450px style="border:0px; text-align:center; line-height:1.3em; border-collapse: separate;"
|-
| style="background:#000000; color:#FFFFFF; font-size:85%%; padding:2px; border:2px; border-style:solid; border-radius:10px;width:225px;" | '''资料分类''' ||style="width:225px;"| '''%s''']=], class))
-- 遍历所有参数,排除已处理的参数
local excludeParams = {
bgcolor = true,
fontcolor = true,
class = true
}
for key, value in pairs(args) do
if not excludeParams[key] and value ~= '' then
table.insert(output, string.format([=[
|-
| style="%s" |'''%s'''||style="width:225px"|'''%s''']=], style, key, value))
end
end
table.insert(output, '|}')
return table.concat(output, '\n')
end
return p