Module:User:Litzsch/Sandbox

local p = {} local frame

local cargoQuery = mw.ext.cargo.query local color = require( 'Module:Color' )._main local getArgs = require( 'Module:Arguments' ).getArgs

local function getCargoData( where ) local abilityData = cargoQuery( 'abilities', 'title, source, image, type', {   where = where,    groupBy = 'source, title'  } ) return abilityData end

local function mSkillListHead( args ) frame = frame or mw.getCurrentFrame return frame:expandTemplate{ title = 'SkillListHead', args = args } end

local function mSkillListTail frame = frame or mw.getCurrentFrame return frame:expandTemplate{ title = 'SkillListTail' } end

local function mSkillListLite( abilityData ) local typeColor = color{ abilityData.type } local sectionLink = abilityData.source .. '#' .. abilityData.title local imageLink = string.format( '24px|link=%s', abilityData.image, sectionLink ) local sourceLink = string.format( '%s', abilityData.source ) local nameLink = string.format( '%s', sectionLink, abilityData.title ) local li = mw.html.create( 'li' ) :addClass( 'skilllist-lite' ) :css( 'background-color', typeColor ) :wikitext( string.format( '%s %s - %s', imageLink, sourceLink, nameLink ) ) return tostring( li ) end

function p.main( frame ) local args = getArgs( frame ) local cargoData = getCargoData( args.where ) local out = {} for i, abilityData in ipairs( cargoData ) do   out[i] = mSkillListLite( abilityData ) end table.insert( out, 1, mSkillListHead( args ) ) table.insert( out, mSkillListTail ) return table.concat( out ) end

return p