七日内新公告:全站维护公告
  • 你好~!欢迎来到萌娘百科镜像站!如需查看或编辑,请联系本站管理员注册账号。
  • 本镜像站和其他萌娘百科的镜像站无关,请注意分别。

Module:学园都市资料/item

猛汉♂百科,万男皆可猛的百科全书!转载请标注来源页面的网页链接,并声明引自猛汉百科。内容不可商用。
跳转到导航 跳转到搜索
模块文档  [创建] [刷新]
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