Module:SimpleInfobox: Difference between revisions
From Chalo Chatu, Zambia online encyclopedia
Jump to navigationJump to search
Chalochatu (talk | contribs) Created page with "local p = {} function p.infobox(frame) local args = frame:getParent().args local root = mw.html.create('table') :addClass('infobox') :css('border','1px solid #aaa') :css('border-collapse','collapse') :css('background','#f8f8f8') :css('font-size','90%') :css('line-height','1.4') :css('width','23em') :css('margin','0.5em') -- Title if args.title and args.title:match('%S') then root:ta..." |
Chalochatu (talk | contribs) No edit summary |
||
| Line 1: | Line 1: | ||
-- Module:SimpleInfobox (for Chalo Chatu) | |||
local p = {} | local p = {} | ||
| Line 32: | Line 33: | ||
end | end | ||
-- Fields | -- Fields (label/data pairs) | ||
for i=1,30 do | for i=1,30 do | ||
local label = args['label'..i] | local label = args['label'..i] | ||
| Line 52: | Line 53: | ||
end | end | ||
-- | -- Alias so Template wrappers can call either function name | ||
p.infoboxTemplate = p.infobox | p.infoboxTemplate = p.infobox | ||
return p | return p | ||
Latest revision as of 01:19, 23 July 2025
Documentation for this module may be created at Module:SimpleInfobox/doc
-- Module:SimpleInfobox (for Chalo Chatu)
local p = {}
function p.infobox(frame)
local args = frame:getParent().args
local root = mw.html.create('table')
:addClass('infobox')
:css('border','1px solid #aaa')
:css('border-collapse','collapse')
:css('background','#f8f8f8')
:css('font-size','90%')
:css('line-height','1.4')
:css('width','23em')
:css('margin','0.5em')
-- Title
if args.title and args.title:match('%S') then
root:tag('caption')
:css('font-size','110%')
:css('font-weight','bold')
:css('padding','.25em')
:wikitext(args.title)
end
-- Image
if args.image and args.image:match('%S') then
root:tag('tr')
:tag('td')
:attr('colspan','2')
:css('text-align','center')
:css('padding','.25em')
:wikitext('[[File:' .. args.image .. '|' .. (args.image_size or '200px') .. ']]')
end
-- Fields (label/data pairs)
for i=1,30 do
local label = args['label'..i]
local data = args['data'..i]
if (label and label:match('%S')) or (data and data:match('%S')) then
local tr = root:tag('tr')
tr:tag('th')
:css('background','#eaeaea')
:css('text-align','left')
:css('padding','.2em .5em')
:wikitext(label or '')
tr:tag('td')
:css('padding','.2em .5em')
:wikitext(data or '')
end
end
return tostring(root)
end
-- Alias so Template wrappers can call either function name
p.infoboxTemplate = p.infobox
return p