Module:LocationInfo
From Little Tail Wiki
Documentation for this module may be created at Module:LocationInfo/doc
local capiunto = require 'capiunto'
local p = {}
function p.main(frame)
local args = frame:getParent().args
-- Set header style, defaulting to 'background-color:grey' if not provided
local headerStyle = args.headerstyle and args.headerstyle ~= '' and
string.format('background-color:%s;', args.headerstyle) or 'background-color:grey;'
-- Create the infobox
local retval = capiunto.create({
title = tostring(mw.title.getCurrentTitle()),
headerStyle = headerStyle,
})
-- Add image and caption
if args.image then
retval:addImage(args.image, args.caption or '')
end
-- Add a general header
retval:addHeader('Info.')
-- Add rows only for fields that are not empty
local rows = {
{ 'Origin Country', args.origin },
{ 'Namesake', args.namesake },
{ 'Greater Area', args.greaterarea },
{ 'Country', args.country },
{ 'Capital', args.capital },
{ 'Ruler', args.ruler },
{ 'Demographic', args.demographic },
{ 'Inhabitants', args.inhabitants },
}
for _, row in ipairs(rows) do
local label, value = row[1], row[2]
if value and value ~= '' then
retval:addRow(label, value)
end
end
return retval
end
return p