Module:Crew

local util_link = require('Module:LinkUtil') local util_text = require('Module:TextUtil') local p = {} --p stands for package -- local h = {} --h stands for helper (not currently needed)

--for use when building crew credit templates (in the style of ) function p.generateCredit(frame) --get frames and args local parentFrame = frame:getParent local args = frame.args local parentArgs = parentFrame.args --initialise the output - it needs to be a blank string so that something is output at the end even if that something is blank local outputString = "" --process arguments local credit = args["credit"] local varname if args["varname"] and args["varname"] ~= "" then varname = args["varname"] else varname = credit end local smw = args["smw"] local display if args["display"] and args["display"] ~= "" then display = args["display"] else display = util_text.titleCase(util_link.stripDab(credit)) end local notPlural = args["notPlural"] --check if variable is needed in the usuage of the credit template if parentArgs[varname] and parentArgs[varname] ~= "" then --if it is, add it to the output outputString = " - " .. util_link.stripDab(parentArgs[varname]) .. "" --also loop through also further variables for this credit (e.g. for director, director2, director3, etc are also checked) local done = false local count = 2 while not done do if parentArgs[varname .. tostring(count)] and parentArgs[varname .. tostring(count)] ~= "" then outputString = outputString .. ", " .. util_link.stripDab(parentArgs[varname .. tostring(count)]) .. "" count = count + 1 else done = true end end --add the name of the credit with an S if needed, along with the * to form a list. if count > 2 and (not notPlural or notPlural == "") then outputString = "* " .. display .. "s" .. outputString else outputString = "* " .. display .. "" .. outputString end end return outputString end

return p