Module:RecursiveSelectiveList: Difference between revisions
EnWikiAdmin (talk | contribs) No edit summary |
EnWikiAdmin (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
function p.main(frame) | |||
function p. | local args = frame:getParent().args | ||
local categoryName = args['categoryName'] | |||
local limit = tonumber(args['limit']) or 10 | |||
if not categoryName then | |||
return "Error: Please provide a category name." | |||
return "Error: | |||
end | end | ||
-- | -- Fetch category members | ||
local category = mw.title.new("Category:" .. categoryName) | |||
return "Error: | if not category then | ||
return "Error: Invalid category name." | |||
end | end | ||
local members = {} | |||
for member in category:members() do | |||
for | if #members >= limit then | ||
table.insert( | break | ||
end | |||
table.insert(members, "* [[" .. member.fullText .. "]]") | |||
end | end | ||
if #members == 0 then | |||
return "No pages found in the category." | |||
return " | |||
end | end | ||
return table.concat(members, "\n") | |||
return | |||
end | end | ||
return p | return p |
Revision as of 06:55, 22 December 2024
Documentation for this module may be created at Module:RecursiveSelectiveList/doc
local p = {}
function p.main(frame)
local args = frame:getParent().args
local categoryName = args['categoryName']
local limit = tonumber(args['limit']) or 10
if not categoryName then
return "Error: Please provide a category name."
end
-- Fetch category members
local category = mw.title.new("Category:" .. categoryName)
if not category then
return "Error: Invalid category name."
end
local members = {}
for member in category:members() do
if #members >= limit then
break
end
table.insert(members, "* [[" .. member.fullText .. "]]")
end
if #members == 0 then
return "No pages found in the category."
end
return table.concat(members, "\n")
end
return p