Module:Etraud/Sandbox1: Difference between revisions

From Pixlies
Content deleted Content added
No edit summary
No edit summary
 
(5 intermediate revisions by the same user not shown)
Line 1:
local p = {}
 
local function addCategory(frame, pronoun)
local category = "Category:Players who use " .. pronoun .. ""
return frame:preprocess("[[" .. category .. "]]")
end
 
function p.pronoun(frame)
Line 16 ⟶ 11:
 
local selectedPronouns = {}
local categories = {}
 
for i, arg in ipairs(args) do
if pronouns[arg] then
table.insert(selectedPronouns, pronouns[arg])
addCategorytable.insert(framecategories, "[[Category:Players who are a " .. pronouns[arg] .. "]]")
end
end
Line 27 ⟶ 23:
return "No valid pronouns specified."
else
return table.concat(selectedPronouns, "/") .. table.concat(categories)
end
end

Latest revision as of 06:47, 26 July 2023

Documentation for this module may be created at Module:Etraud/Sandbox1/doc

local p = {}

function p.pronoun(frame)
    local args = frame.args

    local pronouns = {
        he = "he",
        she = "she",
        they = "they"
    }

    local selectedPronouns = {}
    local categories = {}

    for i, arg in ipairs(args) do
        if pronouns[arg] then
            table.insert(selectedPronouns, pronouns[arg])
            table.insert(categories, "[[Category:Players who are a " .. pronouns[arg] .. "]]")
        end
    end

    if #selectedPronouns == 0 then
        return "No valid pronouns specified."
    else
        return table.concat(selectedPronouns, "/") .. table.concat(categories)
    end
end

return p