Module:TagList

From Eco - English Wiki
Revision as of 22:28, 2 December 2024 by StalEF (talk | contribs)

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:


local p = {}

local Utils = require('Module:Utils')
local IconUtils = require('Module:IconUtils')
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 tagList = TagData.tags
  local text = ''
  
  --Check Passes
  if list ~= 'tags' then return ' Incorrect use of pass. ' end

  text = '<div class="row">\n'

      for k,v in pairs(tagList) do
      local tagLink = L.t('%s Tag'):format(n)
      local tagID = 'Tags'
      text = text .. '<div class="col-lg-2">\n'
      text = text .. IconUtils.main{ name = tagID, size = 32, style = 2, link = tagLink }
      text = text .. '</div>\n'
      end

    text = text .. '</div>'

  return text
end

return p