Module:User:DTLHS/subpages
Jump to navigation
Jump to search
- This module sandbox lacks a documentation subpage. You may create it.
- Useful links: root page • root page’s subpages • links • transclusions • testcases • user page • user talk page • userspace
This is a private module sandbox of DTLHS, for his own experimentation. Items in this module may be added and removed at DTLHS's discretion; do not rely on this module's stability.
export = {}
function namespace(title)
for i in mw.ustring.gmatch(title, '[^:]+:') do
return i
end
return ''
end
function load_page(frame, pagename)
return frame:expandTemplate{ title = ':' .. pagename }
end
function all_subpages(frame, pagename)
local result = {}
local index = mw.text.unstrip(frame:preprocess('{{Special:PrefixIndex/'..pagename..'/}}'))
local ns = namespace(pagename)
for link in mw.ustring.gmatch(index, "<a.->(.-)</a>") do
table.insert(result, ns..link)
end
return result
end
function export.display(frame)
local args = frame:getParent().args
local pagename = args[1]
local pages = all_subpages(frame, pagename)
local result = {}
for i, v in ipairs(pages) do
table.insert(result, load_page(frame, v))
end
return table.concat(result, '\n\n')
end
return export