Module:InfoboxCustom: Difference between revisions
From Elwiki
No edit summary |
No edit summary |
||
Line 7: | Line 7: | ||
function p.main(frame) | function p.main(frame) | ||
local args = getArgs(frame); | local args = getArgs(frame); | ||
if args.title == nil then | |||
args.title = args['Name'] | |||
title = args['Name'] | |||
end | end | ||
if title == nil then | if args.title == nil then | ||
title = args | args.title = args.name | ||
end | end | ||
local infobox = require('Module:InfoboxProto').main(frame, title); | local infobox = require('Module:InfoboxProto').main(frame, title); |
Revision as of 15:56, 17 May 2022
Documentation for this module may be created at Module:InfoboxCustom/doc
require('Module:CommonFunctions')
require('Module:InfoboxProto');
local getArgs = require('Module:Arguments').getArgs
local p = {}
-- Main process
function p.main(frame)
local args = getArgs(frame);
if args.title == nil then
args.title = args['Name']
end
if args.title == nil then
args.title = args.name
end
local infobox = require('Module:InfoboxProto').main(frame, title);
local divclass = args.divclass;
if divclass == nil then
divclass = 'custom'
end
infobox:addClass('infobox-' .. divclass);
local i = 1;
for k, v in spairs(args) do
if string.match(k, 'data[0-9]+') ~= nil then
addField('data' .. i, args['label' .. i])
i = i + 1
end
end
return tostring(infobox);
end
return p