Module:RecursiveSelectiveList: Difference between revisions

From Ikwipedia
No edit summary
No edit summary
Line 3: Line 3:


function p.main(frame)
function p.main(frame)
     -- Retrieve parameters from the template invocation
     -- Get all arguments passed to the module
     local args = frame:getParent().args
     local args = frame:getParent().args
    local pageName = args["pageName"] -- Explicitly fetch the 'pageName' argument


     -- Check if 'pageName' is provided
     -- Debug: Display all arguments
     if not pageName or pageName == "" then
     local debugInfo = "Arguments passed:\n"
         return "Error: 'pageName' parameter is missing or empty."
    for key, value in pairs(args) do
         debugInfo = debugInfo .. key .. " = " .. (value or "nil") .. "\n"
     end
     end


     -- Fetch content for the specified page
     return debugInfo -- Return the debug information
    local pageContent = mw.title.new(pageName):getContent()
 
    -- Handle cases where the page doesn't exist or has no content
    if not pageContent then
        return "Error: The page '" .. pageName .. "' does not exist or has no content."
    end
 
    return pageContent
end
end


return p
return p

Revision as of 07:12, 22 December 2024

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

local p = {}
local mw = require('mw')

function p.main(frame)
    -- Get all arguments passed to the module
    local args = frame:getParent().args

    -- Debug: Display all arguments
    local debugInfo = "Arguments passed:\n"
    for key, value in pairs(args) do
        debugInfo = debugInfo .. key .. " = " .. (value or "nil") .. "\n"
    end

    return debugInfo -- Return the debug information
end

return p