跳转到内容
主菜单
主菜单
移至侧栏
隐藏
导航
首页
最近更改
随机页面
特殊页面
還阔以
搜索
搜索
外观
创建账号
登录
个人工具
创建账号
登录
查看“︁模块:Infobox”︁的源代码
模块
讨论
English
阅读
查看源代码
查看历史
工具
工具
移至侧栏
隐藏
操作
阅读
查看源代码
查看历史
清除缓存
常规
链入页面
相关更改
页面信息
Cargo数据
外观
移至侧栏
隐藏
←
模块:Infobox
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
local p = {} function p.main(frame) local args = frame:getParent().args return p._renderInfobox(args) end function p._renderInfobox(args) local infobox = {} -- 开始 Infobox 表格 table.insert(infobox, '{| class="infobox"') -- 标题行 if args.title then table.insert(infobox, '|+ | ' .. args.title) end -- 图片行 if args.image then table.insert(infobox, '|-') table.insert(infobox, '| colspan="2" | [[' .. args.image .. '|250px]]') end -- 处理字段和分组 local groups = {} local currentGroup = {title = nil, fields = {}} local hasExplicitGroups = false -- 按参数顺序处理 for key, value in pairs(args) do if key ~= "title" and key ~= "image" then -- 检查是否是分组标题 local groupNum = key:match("^group(%d+)_title$") if groupNum then hasExplicitGroups = true -- 保存前一个分组(如果有字段) if #currentGroup.fields > 0 or currentGroup.title then table.insert(groups, currentGroup) end -- 开始新分组 currentGroup = {title = value, fields = {}} else -- 普通字段,添加到当前分组 table.insert(currentGroup.fields, {name = key, value = value}) end end end -- 添加最后一个分组 if #currentGroup.fields > 0 or currentGroup.title then table.insert(groups, currentGroup) end -- 渲染分组和字段 for _, group in ipairs(groups) do if group.title then table.insert(infobox, '|-') table.insert(infobox, '! colspan="2" | ' .. group.title) end for _, field in ipairs(group.fields) do if field.value and field.value ~= "" then table.insert(infobox, '|-') table.insert(infobox, '! ' .. field.name) table.insert(infobox, '| ' .. field.value) end end end -- 结束表格 table.insert(infobox, '|}') return table.concat(infobox, '\n') end return p
该页面使用的模板:
模块:Infobox/doc
(
查看源代码
)
返回
模块:Infobox
。
搜索
搜索
查看“︁模块:Infobox”︁的源代码
添加话题