Content added Content deleted
m (added default) |
mNo edit summary |
||
Line 75: | Line 75: | ||
) |
) |
||
:addHeader({ tag = 'th', content = 'Logo'}) |
:addHeader({ tag = 'th', content = 'Logo'}) |
||
:addImage{{ tag = ' |
:addImage{{ tag = 'argtd', content = 'group image' }} |
||
:addHeader({ tag = 'th', content = 'Information' }) |
:addHeader({ tag = 'th', content = 'Information' }) |
||
:addRow( |
:addRow( |
Revision as of 02:14, 27 June 2021
This module depends on the following other modules: |
To generate {{Infobox unit}}, invoke using the main function.
--------------------------
-- Module for [[Template:Infobox Group]]
------------------------
local builder = require('Module:InfoboxBuilder')
local p = {}
local categories = ""
local function split(inputstr, sep)
if sep == nil then
sep = "%s"
end
local t={}
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
table.insert(t, str)
end
return t
end
local function formatImage(image_name)
return string.format("[[File:%s|300px]]", image_name)
end
local function formatMembers(arg)
if arg then
return table.concat(split(arg, ","), "<br>")
end
return nil
end
function p.main(frame)
local args = frame:getParent().args
local infobox = builder.new();
infobox:setName('Infobox Group')
:setWidth("330px")
infobox:setParams{
{ name = 'unit name', default = mw.title.getCurrentTitle().text },
{ name = 'group image', func = formatImage },
{ name = 'japanese' },
{ name = 'romaji' },
{ name = 'english' },
{ name = 'logo', func = formatImage },
{ name = 'members', func = formatMembers },
{ name = 'virtual singers', func = formatMembers }
}
infobox
:setArgs(args)
infobox
:addHeader({ tag = 'argth', content = 'unit name' })
:addRow(
{
{ tag = 'th', content = 'Japanese', colspan = 12 },
{ tag = 'argtd', content = 'japanese', colspan = 18 }
},
{ hideIfEmpty = { 'japanese' } }
)
:addRow(
{
{ tag = 'th', content = 'Romaji', colspan = 12 },
{ tag = 'argtd', content = 'romaji', colspan = 18 }
},
{ hideIfEmpty = { 'romaji' } }
)
:addRow(
{
{ tag = 'th', content = 'English', colspan = 12 },
{ tag = 'argtd', content = 'english', colspan = 18 }
},
{ hideIfEmpty = { 'english' } }
)
:addHeader({ tag = 'th', content = 'Logo'})
:addImage{{ tag = 'argtd', content = 'group image' }}
:addHeader({ tag = 'th', content = 'Information' })
:addRow(
{
{ tag = 'th', content = 'Members', colspan = 12 },
{ tag = 'argtd', content = 'members', colspan = 18 }
}
)
:addRow(
{
{ tag = 'th', content = 'Virtual Singers', colspan = 12 },
{ tag = 'argtd', content = 'virtual singers', colspan = 18 }
}
)
if mw.title.getCurrentTitle().namespace == 0 then
categories = "[[Category:Groups]]" .. categories
end
return infobox:tostring() .. categories
end
return p