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 = {} | ||
local mw = require('mw') | |||
function p. | -- 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." | |||
if not | |||
return "Error: | |||
end | end | ||
local | -- Use the MediaWiki API to fetch the page content | ||
local status, content = pcall(function() | |||
return mw.title.new(pageTitle):getContent() | |||
end) | |||
end | |||
if | -- Handle errors or return content | ||
return " | if not status or not content then | ||
return "Error: Unable to fetch content for page '" .. pageTitle .. "'." | |||
end | end | ||
return | return content or "Error: Page content is empty." | ||
end | end | ||
-- Function to be invoked from templa |
Revision as of 07:01, 22 December 2024
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