Module:RecursiveSelectiveList

From Ikwipedia
Revision as of 07:01, 22 December 2024 by EnWikiAdmin (talk | contribs)

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

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

-- Function to fetch content from a specified page
function p.getPageContent(pageTitle)
    -- Check if a page title is provided
    if not pageTitle or pageTitle == "" then
        return "Error: No page title provided."
    end

    -- Use the MediaWiki API to fetch the page content
    local status, content = pcall(function()
        return mw.title.new(pageTitle):getContent()
    end)

    -- Handle errors or return content
    if not status or not content then
        return "Error: Unable to fetch content for page '" .. pageTitle .. "'."
    end

    return content or "Error: Page content is empty."
end

-- Function to be invoked from templa