Module:Infobox
外观
-- Module:Infobox -- Generates character and item infoboxes without wikitext pipe-parsing issues. local p = {}
-- Append a label/value row only when value is non-empty. local function row(label, value)
if not value or mw.text.trim(value) == then return end return '\n|-\n! ' .. label .. '\n| ' .. mw.text.trim(value)
end
-- Resolve display name: use |name= or fall back to PAGENAME. local function displayName(args, frame)
local n = args.name and mw.text.trim(args.name) or
if n == then n = frame:callParserFunction('PAGENAME') end
return n
end
-- Image row spanning both columns. local function imageRow(args)
local img = args.image and mw.text.trim(args.image) or
if img == then return end
return '\n|-\n! colspan="2" style="text-align:center;" | 文件:' .. img .. ''
end
function p.character(frame)
local args = frame:getParent().args
local name = displayName(args, frame)
local t = '{| class="infobox biography vcard"\n|+ \'\'\ .. name .. '\'\'\
t = t .. imageRow(args)
t = t .. row('别称', args.aliases)
t = t .. row('所处地', args.location)
t = t .. row('所属势力', args.faction)
t = t .. row('身份', args.identity)
t = t .. row('职位', args.position)
t = t .. row('年龄', args.age)
t = t .. row('种族', args.race)
t = t .. row('修为', args.cultivation)
t = t .. row('资质', args.aptitude)
t = t .. row('技能', args.skills)
t = t .. '\n|}'
return frame:preprocess(t)
end
function p.item(frame)
local args = frame:getParent().args
local name = displayName(args, frame)
local t = '{| class="infobox biography vcard"\n|+ \'\'\ .. name .. '\'\'\
t = t .. imageRow(args)
t = t .. row('物品品阶', args.grade)
t = t .. row('物品类型', args['type'])
t = t .. row('持有人', args.owner)
t = t .. row('打造人', args.maker)
t = t .. row('材质', args.material)
t = t .. row('用途', args.use)
t = t .. row('技能/能力', args.ability)
t = t .. '\n|}'
return frame:preprocess(t)
end
return p