Module:TagsList: Difference between revisions

From Eco - English Wiki
[checked revision][checked revision]
No edit summary
No edit summary
 
(11 intermediate revisions by 2 users not shown)
Line 3: Line 3:
local p = {}
local p = {}


-- Grabs args from the parent frame
local Utils = require('Module:Utils')
-- Trims and parses the args into a table, then returns the table
local L = require('Module:Localization')
function norm()
    local origArgs = mw.getCurrentFrame():getParent().args
    local args = {}
   
    for k, v in pairs( origArgs ) do
        v = mw.text.trim( tostring( v ) )
        if v ~= '' then
            args[k] = v
        end
    end
   
    return args
end


-- Main entry point for the Module
-- Main entry point for the Module
function p.main()
function p.main(frame)
    -- get args from the Template
  -- get args from the Template
     local args = norm()
  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 itemData = mw.loadData("Module:ItemData")
  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 .. '=== Tags List ===\n'
    tagsList = tagsList .. '<div style=\"column-count:3;-moz-column-count:3;-webkit-column-count:3\">\n'
      
      
if args.list == nil or args.list == '' then
    for k, v in pairs(itemData.tags) do
        return '\'list\' must be specified.'
      if itemData.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 .. '* [[' .. link .. '|' .. n .. ']]\n'
     end
     end
     tagsList = tagsList .. '[[Category:Tags]]</div>'
    -- assign variables for list
  end
    local list = args.list
    -- load lists
     local itemData = require( "Module:ItemData" )
local tagList = ''
 
--Check Passes
if list ~= 'tags' then
        return tagsList .. ' Incorrect use of pass. '
    end
local a = {}
--Talent List
if list == 'tags' then
tagsList = tagsList .. '=== Tags List ===\n' 
tagsList = tagsList .. '<div style=\"column-count:3;-moz-column-count:3;-webkit-column-count:3\">\n'
   
for k,v in pairs(itemData.tags) do       
            if itemData.tags[k] ~= nil or itemData.tags[k] ~= '' then
              table.insert(a,k)
            end
        end
        table.sort(a)
        for i,n in ipairs(a) do
            tagsList = tagsList .. '* [[' .. k .. ']]\n'               
        end
tagsList = tagsList .. '</div>'
end


return tagsList
  return tagsList
end
end


return p
return p

Latest revision as of 16:28, 19 April 2021

Documentation[edit source]

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[edit source]

Original SkillList was created by Fyre (FishAus) then edited by Scotty (ZeelNightwolf) and used as a base for TagsList.


-- 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 itemData = mw.loadData("Module:ItemData")
  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 .. '=== Tags List ===\n'
    tagsList = tagsList .. '<div style=\"column-count:3;-moz-column-count:3;-webkit-column-count:3\">\n'
    
    for k, v in pairs(itemData.tags) do
      if itemData.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 .. '* [[' .. link .. '|' .. n .. ']]\n'
    end
    tagsList = tagsList .. '[[Category:Tags]]</div>'
  end

  return tagsList
end

return p