Module:TagList
From Eco - English Wiki
This module provides the back end functionality of the Template:TagsList.
If the template is passed, this module creates a list using details from the following Modules:
Credit
Original SkillList was created by Fyre (FishAus) then edited by Scotty (ZeelNightwolf) and used as a base for TagsList.
local p = {}
local Utils = require('Module:Utils')
local L = require('Module:Localization')
-- Main entry point for the Module
function p.main(frame)
-- get args from the Template
local args = Utils.normaliseArgs(frame)
if args.list == nil or args.list == '' then
return '\'list\' must be specified.'
end
-- assign variables for list
local list = args.list
-- load lists
local TagData = mw.loadData("Module:TagData")
local tagsList = ''
--Check Passes
if list ~= 'tags' then
return tagsList .. ' Incorrect use of pass. '
end
local a = {}
--Tags List
if list == 'tags' then
tagsList = tagsList .. '<div class="row">\n'
for k, v in pairs(TagData.tags) do
if TagData.tags[k] ~= nil then
table.insert(a, k)
end
end
table.sort(a)
for i, n in ipairs(a) do
local link = L.t('%s Tag'):format(n)
tagsList = tagsList .. '<div class="col-lg-2">\n'
tagsList = tagsList .. '{{Icon|name=' .. n .. '|size=32}}'
tagsList = tagsList .. '[[' .. link .. '|' .. n .. ']]\n'
tagsList = tagsList .. '</div>\n'
end
tagsList = tagsList .. '[[Category:Tags]]</div>'
end
return tagsList
end
return p