Module:Sandbox/Awesome Aasim/Categories
{{|}} 1993 births|Living people|21st-century American actresses|21st-century American singer-songwriters|21st-century American women singers|Actresses from Florida|American actors with disabilities|American child actresses|American former Christians|American LGBTQ rights activists|American musical theatre actresses|American people of Italian descent|American sopranos|American television actresses|American women pop singers|American women singer-songwriters|Anti-bullying activists|Brit Award winners|American child pop musicians|Kabbalists|Crime witnesses|American dance-pop musicians|American feminist musicians|Former Roman Catholics|Grammy Award winners|Judges in American reality television series|MTV Europe Music Award winners|Nickelodeon people|People with post-traumatic stress disorder|Republic Records artists|Singer-songwriters from Florida|Singers with a four-octave vocal range|Universal Music Group artists|American women in electronic music|American musicians with disabilities|Singers with disabilities|Survivors of terrorist attacks
Usage
{{#invoke:Sandbox/Awesome Aasim/Categories|function_name}}
local p = {}
p._cachedData = {}
local function getCategoriesFromWikitext(wikitext)
local categories = {}
for category in mw.ustring.gmatch(wikitext, "%[%[Category:([%w%s%-_]+)%]%]") do
table.insert(categories, category)
end
return categories
end
function p.getCategories(title, skipProcessing)
title = tostring(title)
-- if cached then return that
if p._cachedData[title] ~= nil then
mw.log("Cached")
return p._cachedData[title]
else
mw.incrementExpensiveFunctionCount()
local wikitext = skipProcessing and mw.title.new(title):getContent() or mw.getCurrentFrame():preprocess(mw.title.new(title):getContent())
local categories = getCategoriesFromWikitext(wikitext)
mw.log("Caching...")
p._cachedData[title] = categories
return categories
end
end
function p.main(frame)
local args = require('Module:Arguments').getArgs(frame)
return table.concat(p.getCategories(args[1], require("Module:Yesno")(args[2])), '|')
end
return p