Module:RecursiveSelectiveList: Difference between revisions
EnWikiAdmin (talk | contribs) No edit summary |
EnWikiAdmin (talk | contribs) No edit summary |
||
Line 2: | Line 2: | ||
local mw = require('mw') | local mw = require('mw') | ||
function p.main(frame) | |||
function p. | -- Retrieve parameters from the template invocation | ||
-- | local args = frame:getParent().args | ||
local pageName = args.pageName or "Main Page" -- Default to "Main Page" if no pageName is provided | |||
-- Use the MediaWiki API to fetch the page | -- Use the MediaWiki API to fetch the content of the page | ||
local | local pageContent = mw.title.new(pageName):getContent() | ||
-- Handle | -- Handle cases where the page might not exist | ||
if not | if not pageContent then | ||
return "Error: | return "Error: The page '" .. pageName .. "' does not exist or has no content." | ||
end | end | ||
return | -- Optionally process the content, here simply returning it | ||
return pageContent | |||
end | end | ||
return p |
Revision as of 07:06, 22 December 2024
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:getParent().args
local pageName = args.pageName or "Main Page" -- Default to "Main Page" if no pageName is provided
-- Use the MediaWiki API to fetch the content of the page
local pageContent = mw.title.new(pageName):getContent()
-- Handle cases where the page might not exist
if not pageContent then
return "Error: The page '" .. pageName .. "' does not exist or has no content."
end
-- Optionally process the content, here simply returning it
return pageContent
end
return p