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') | local mw = require('mw') | ||
function p.main(frame) | |||
-- Call the debug function to display all information | |||
return p.debug(frame) | |||
end | |||
function p.debug(frame) | function p.debug(frame) |
Revision as of 07:31, 22 December 2024
Documentation for this module may be created at Module:RecursiveSelectiveList/doc
local p = {}
local mw = require('mw')
function p.main(frame)
-- Call the debug function to display all information
return p.debug(frame)
end
function p.debug(frame)
local html = mw.html.create("div"):addClass("debug-output")
-- Retrieve parameters from the template invocation
local args = frame.args
html:tag("h3"):wikitext("Debugging Information")
-- Add each parameter as a key-value pair
html:tag("h4"):wikitext("Template Arguments:")
local argsList = html:tag("ul")
for key, value in pairs(args) do
argsList:tag("li"):wikitext(key .. " = " .. (value or "nil"))
end
-- Example of debugging mw.title.new
local pageName = args.pageName or "No pageName provided"
html:tag("h4"):wikitext("Page Name Provided:")
html:tag("p"):wikitext(pageName)
if pageName ~= "No pageName provided" then
local titleObject = mw.title.new(pageName)
if titleObject then
html:tag("h4"):wikitext("Title Object Debugging:")
local titleList = html:tag("ul")
titleList:tag("li"):wikitext("Full Text: " .. (titleObject.fullText or "nil"))
titleList:tag("li"):wikitext("Namespace: " .. (titleObject.namespace or "nil"))
titleList:tag("li"):wikitext("ID: " .. (titleObject.id or "nil"))
-- Try to get content
local pageContent = titleObject:getContent()
if pageContent then
html:tag("h4"):wikitext("Page Content:")
html:tag("pre"):wikitext(pageContent)
else
html:tag("h4"):wikitext("Page Content:"):tag("p"):wikitext("No content found or page does not exist.")
end
else
html:tag("h4"):wikitext("Title Object:"):tag("p"):wikitext("Failed to create title object for page name.")
end
end
return tostring(html)
end
return p