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.main(frame) | ||
local categoryName = frame.args.categoryName or "Category:Example" -- Default category | |||
local | local limit = tonumber(frame.args.limit) or 10 -- Default limit | ||
local | |||
-- | -- Fetch category members | ||
local members = mw.site.categoryMembers(categoryName, nil, limit) | |||
-- Build the output | |||
local results = {} | |||
for _, member in ipairs(members) do | |||
table.insert(results, string.format("* [[%s]]", member.title)) | |||
end | end | ||
-- Return the results as a bulleted list | |||
return table.concat(results, "\n") | |||
-- Return the | |||
return table.concat( | |||
end | end | ||
return p | return p |
Revision as of 07:23, 22 December 2024
Documentation for this module may be created at Module:RecursiveSelectiveList/doc
local p = {}
function p.main(frame)
local categoryName = frame.args.categoryName or "Category:Example" -- Default category
local limit = tonumber(frame.args.limit) or 10 -- Default limit
-- Fetch category members
local members = mw.site.categoryMembers(categoryName, nil, limit)
-- Build the output
local results = {}
for _, member in ipairs(members) do
table.insert(results, string.format("* [[%s]]", member.title))
end
-- Return the results as a bulleted list
return table.concat(results, "\n")
end
return p