This module depends on the following other modules: |
To generate {{Infobox avatar accessory}}, invoke using the main function.
--------------------------
-- Module for [[Template:Infobox avatar accessory]]
------------------------
local getArgs = require('Module:Arguments').getArgs
local InfoboxBuilder = require('Module:InfoboxBuilder')
local DisplayFns = require('Module:DisplayFunctions')
local ProcessingFns = require('Module:ProcessingFunctions')
local p = {}
function p.main(frame)
local args = getArgs(frame, { wrappers = 'Template:Infobox avatar accessory' })
local infobox = InfoboxBuilder.new()
infobox:setName('Infobox avatar accessory')
:setParams{
{ name = 'accessory id' },
{ name = 'accessory name', default = mw.title.getCurrentTitle().text },
{ name = 'thumbnail' },
{ name = 'japanese' },
{ name = 'romaji' },
{ name = 'english' },
{ name = 'date' },
{ name = 'acquire', fn = ProcessingFns.stringToArray(',') },
{ name = 'price', fn = ProcessingFns.stringToArray(';') },
{ name = 'card' },
{ name = 'card id' },
}
:setArgs(args)
:processArgs()
infobox
:addHeader({ tag = 'argth', content = 'accessory name' })
:addImage({
{ tag = 'argtd', content = 'thumbnail', fn = DisplayFns.image('128px') },
})
:addRow(
{
{ tag = 'th', content = 'Japanese' },
{ tag = 'argtd', content = 'japanese' }
},
{ hideIfEmpty = { 'japanese' } }
)
:addRow(
{
{ tag = 'th', content = 'Romaji' },
{ tag = 'argtd', content = 'romaji' }
},
{ hideIfEmpty = { 'romaji' } }
)
:addRow(
{
{ tag = 'th', content = 'English' },
{ tag = 'argtd', content = 'english' }
},
{ hideIfEmpty = { 'english' } }
)
:addHeader({ tag = 'th', content = 'Acquisition Information'}, { subheader = true })
:addRow({
{ tag = 'th', content = 'Release date' },
{ tag = 'argtd', content = 'date' },
})
:addRow({
{
tag = 'argth',
content = 'acquire',
fn = DisplayFns.pluralHeader({ 'Acquition method', 'Acquition methods'})
},
{
tag = 'argtd',
content = 'acquire',
fn = DisplayFns.list('unbulleted')
},
})
:addRow(
{
{ tag = 'th', content = 'Price' },
{ tag = 'argtd', content = 'price', fn = DisplayFns.list('unbulleted') }
},
{ hideIfEmpty = { 'price' } }
)
:addRow(
{
{ tag = 'th', content = 'Associated card' },
{ tag = 'argtd', content = 'card', fn = DisplayFns.link }
},
{ hideIfEmpty = { 'card' } }
)
local categories = ""
if mw.title.getCurrentTitle().namespace == 0 then
categories = "[[Category:Avatar accessories]]" .. infobox:getCategories()
end
return infobox:tostring() .. categories
end
return p