Module:RecursiveSelectiveList
Documentation for this module may be created at Module:RecursiveSelectiveList/doc
local p = {}
local mw = require('mw')
function p.main(frame)
-- Retrieve parameters from the template invocation
local args = frame.args
local categoryName = args.categoryName
-- Check if 'categoryName' is provided
if not categoryName or categoryName == "" then
return "Error: 'categoryName' parameter is missing or empty."
end
-- Ensure the category name starts with "Category:"
if not categoryName:match("^Category:") then
categoryName = "Category:" .. categoryName
end
-- Fetch the category page content
local categoryPage = mw.title.new(categoryName)
if not categoryPage then
return "Error: Invalid category name '" .. categoryName .. "'."
end
local content = categoryPage:getContent()
-- Handle cases where the page has no content
if not content then
return "The category '" .. categoryName .. "' does not exist or has no content."
end
-- Return the raw content of the category page
return "Raw content of category '" .. categoryName .. "':\n\n" .. content
end
return p