Module:Team roster navbox
Revision as of 07:28, 14 December 2015 by blackwiki>The Earwig (Protected "Module:Team roster navbox": High-risk Lua module: over 20,000 mainspace transclusions ([Edit=Allow only template editors and admins] (indefinite) [Move=Allow only template editors and admins] (indefinite)))
| This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
This module is used to implement {{Team roster navbox}}, a helper template used to implement the individual team roster navboxes for the Major League Baseball teams.
At present, it parses any list<number> arguments to the template and replaces spaces in each list item with in order to prevent wrapping. It then calls Module:Navbox._navbox() to create the navbox. (Note the preprocessing done by Module::Navbox.navbox() has not been copied to this module and so is skipped.)
local me = { }
local Navbox = require('Module:Navbox')
function me.generateRosterNavbox(frame)
local args = { }
local parentArgs = frame:getParent().args
-- Massage the arguments before passing them to the Navbox helper function
for argName, value in pairs(parentArgs) do
if value ~= '' then
if type(argName) == 'string' and mw.ustring.find(argName, '^list') then
local listValues = { }
for entry in mw.text.gsplit(value, '[\n\r]+') do
entry = mw.ustring.gsub(entry, '([^%*])%s+', '%1 ')
table.insert(listValues, entry)
end
value = table.concat(listValues, '\n')
end
args[argName] = value
end
end
-- Note Navbox.navbox() has a kludge to order the parent frame's args
-- into a specific order. For now, this is omitted from this module.
return Navbox._navbox(args)
end -- function me.generateRosterNavbox
return me