Module:MagicalGirl

-- -- Module for Template:Infobox Magical Girl

local getArgs  = require('Module:Arguments').getArgs local InfoboxBuilder = require('Module:InfoboxBuilder') local DisplayFns    = require('Module:DisplayFunctions') local ProcessingFns = require('Module:ProcessingFunctions') local constants = require('Module:Constants')

local p = {}

local function formatColor(color) if color and color ~= nil then return string.format(			"%s  ",			color,			color		); end end

local function formatHometown(list) if list == nil then return nil end return table.concat(list, ' ') end

function p.main(frame) local args = getArgs(frame) local infobox = InfoboxBuilder.new; infobox:setName('Infobox Magical Girl') :setParams{ { name = 'character name', default = mw.title.getCurrentTitle.text }, { name = 'character image' }, { name = 'Native' }, { name = 'Seiyū' }, { name = 'Age' }, { name = 'position' }, { name = 'height' }, { name = 'Hometown', fn = ProcessingFns.stringToArray('\n') }, { name = 'weapon'}, { name = 'Character Song'}, { name = 'wish'}, { name = 'Witch' }, { name = 'color' }, }		:setArgs(args) :processArgs if args['color'] and args['color'] ~= '' then infobox:setHeaderBackgroundColor(args['color']) end

infobox :addHeader({ tag = 'argth', content = 'character name' }) :addImage :addRow(			{				{ tag = 'th', content = 'Native' },				{ tag = 'argtd', content = 'Native' }			}		) :addRow(			{				{ tag = 'th', content = 'Seiyū' },				{ tag = 'argtd', content = 'seiyū' }			}		) :addRow(			{				{ tag = 'th', content = 'Age' },				{ tag = 'argtd', content = 'age' }			}		) :addHeader({ tag = 'th', content = 'Profile' }, { subheader = true }) :addRow(			{				{ tag = 'th', content = 'Height' },				{ tag = 'argtd', content = 'height' }			}		) :addRow(			{				{ tag = 'th', content = 'Hometown' },				{ tag = 'argtd', content = 'Hometown', fn = formatHometown }			},			{ hideIfEmpty = { 'Hometown' } }		) :addRow(			{				{ tag = 'th', content = 'Weapon' },				{ tag = 'argtd', content = 'weapon' }			},			{ hideIfEmpty = { 'weapon' } }		) :addRow(			{				{ tag = 'th', content = 'Character Song' },				{ tag = 'argtd', content = 'charactersong' }			},			{ hideIfEmpty = { 'charactersong' } }		) :addRow(			{				{ tag = 'th', content = 'Wish' },				{ tag = 'argtd', content = 'wish' }			},			{ hideIfEmpty = { 'wish' } }		) :addRow(			{				{ tag = 'th', content = 'Witch' },				{ tag = 'argtd', content = 'witch' }			},			{ hideIfEmpty = { 'witch' } }		) :addRow(			{				{ tag = 'th', content = 'Image color' },				{ tag = 'argtd', content = 'color', fn = formatColor }			}		) local categories = "" if mw.title.getCurrentTitle.namespace == 0 then categories = "" .. categories end

return infobox:tostring .. categories end

return p