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 = util_text.titleCase(args["credit"]) local varname if args["varname"] and args["varname"] ~= "" then varname = args["varname"] else varname = args["credit"] end --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(credit) .. " - " .. 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)] then outputString = outputString .. ", " .. util_link.stripDab(parentArgs[varname .. tostring(count)]) .. "" count = count + 1 else done = true end end end return outputString end

return p